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);
}