contentEditable cursor's parent element

偶尔善良 提交于 2019-12-02 04:53:45

问题


I have a contentEditable HTML element. I would like to get the cursor's parent element. For example, if the cursor is inside a table cell, I would like to display some controls for editing the table. Is this possible? Or am I going to track all key and mousepresses?


回答1:


Example using parentNode:

document.getElementById('editable').onclick = function () {
 alert(this.parentNode.id);   
}


来源:https://stackoverflow.com/questions/7770404/contenteditable-cursors-parent-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!