How to get the selected element inside a contenteditable element
<h2>What I've tried</h2>

<p>I checked out <a href="https://stackoverflow.com/questions/14551134/in-contenteditable-how-can-i-get-a-reference-to-the-element-immediately-precedi">this question</a>, and <a href="https://stackoverflow.com/questions/1197401/how-can-i-get-the-element-the-caret-is-in-with-javascript-when-using-contentedi">this one</a>, the problem is it gives me the content of the current selection, but I want the dom element instead.</p>

<hr>

<h2>What I want to do</h2>

<p>I'm looking for a way to get the tagname of an element that is currently being edited with javascript. For example:</p>

<pre><code>&lt;article contenteditable=true&gt;
    &lt;h2&gt;Some List&lt;/h2&gt;
    &lt;ul&gt;
        &lt;li&gt;Item 1&lt;/li&gt;
        &lt;li&gt;Item *caret here* 2&lt;/li&gt;
        &lt;li&gt;Item 3&lt;/li&gt;
    &lt;/ul&gt;
&lt;/article&gt;
</code></pre>

<p>I want to be able to put the list item into a javascript <code>el</code> variable. So I that I can do for example:</p>

<pre><code>el.tagName
el.className
</code></pre>

<hr>

<p>Does anyone know how to achieve this? Tx :)</p>