Hi,
Let's say I have some HTML code like this:
<body contentEditable="true">
<h1>Some heading text here</h1>
<p>Some text here</p>
</body>
Now the caret (the blinking cursor) is blinking inside the H1 element, let's say in the word "heading". How can I get the name of the element the caret is in with JavaScript? Here I would like to get "h1".
This needs to work only in WebKit (it's embeded in an application). It should preferably also work for selections.
If this is truly trivial, I apologize. My knowledge of JavaScript (and DOM) is sorely lacking.