相关疑难解决方法(0)

获取所选文本的父元素

是否可以在页面中获取所选文本的父元素?例如:

<div class="someparent">

Selection of this text should refer to the 'someparent' class.

<span class="spanparent">If this is selected, the parent should be this span</span>

</div>
Run Code Online (Sandbox Code Playgroud)

因为在获取所选文本时,它通常从窗口或文档中获取它(取决于浏览器),但是可以获取所选文本的父元素吗?

javascript jquery text

15
推荐指数
2
解决办法
2万
查看次数

标签 统计

javascript ×1

jquery ×1

text ×1