javascript - How to extract the tags associated with Cursor location -
how extracts tags associated cursor location. in below html example, when cursor @ "associated", want info tags added text "associated".
<html> <body> how <b>to <font color="#ff000">extract<i> tags associated </i>cursor </b>location</font> </body> </html> here want "b , font, i"
is possible information.
i'm not quite sure you're asking, i'm assuming you're talking regular cursor rather caret.
you this:
var lastelemententered = null; document.onmouseover = function(e) { e = e || window.event; lastelemententered = e.target || e.srcelement; }; document.onmouseout = function() { lastelemententered = null; } function getcursorelementpath() { var tagnames = []; if (lastelemententered) { var node = lastelemententered; while (node && node != document.body) { tagnames.unshift(node.nodename); node = node.parentnode; } } homecoming tagnames; } alert( getcursorelementpath() ); javascript
No comments:
Post a Comment