如何檢測用戶選擇(用鼠標突出顯示)是否在某個元素的子元素中?在html元素中檢測用戶選擇
實施例:
<div id="parent">
sdfsdf
<div id="container">
some
<span>content</span>
</div>
sdfsd
</div>
僞代碼:
if window.getSelection().getRangeAt(0) is a child of #container
return true;
else
return false;
這可能會引發一些光http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac – Shyju
由於您使用jQuery,[插頁](http://www.jquery-plugin.buss.hk/my-plugins/jquery-caret-plugin)非常酷。 – mayhewr
任何人都可以幫忙嗎? – Sam