ユーザーの選択 (マウスでの強調表示) が特定の要素内/子であるかどうかを検出するにはどうすればよいですか?
例:
<div id="parent">
sdfsdf
<div id="container">
some
<span>content</span>
</div>
sdfsd
</div>
擬似コード:
if the entire range of window.getSelection().getRangeAt(0) is within/a child of #container
return true;
else
return false;
更新:これは、範囲内の最上位要素の各親要素を見て、#container と一致するかどうかを確認することで実行できると思います。JavaScriptでこれを書くのに助けが必要です.