Maison  >  Questions et réponses  >  le corps du texte

javascript - DOM 上的 Selection 和 Range 具体是怎样的关系?

项目需要于是折腾了一个 jQuery 插件用来替换编辑区域内容, 在被聚焦时保持光标位置不变:
http://jiyinyiyong.github.io/jquery-swap/
https://github.com/jiyinyiyong/jquery-swap/blob/gh-pages/coffee/swap.coffee#L2
个人感觉 Selection 和 Range, 虽然只是对高版本浏览器进行支持, 但还是很不顺,
似乎 Selection 和 Range 两者的关闭比较复杂,
那一般的理解, 网页上选中高亮的区域, 其实就是一块区域,
那么我通过一个对象操作就好了, 为什么这里使用了两个对象, 并且有这么多属性和方法么?

高洛峰高洛峰2736 Il y a quelques jours617

répondre à tous(0)je répondrai

Pas de réponse
  • Annulerrépondre