This question (to which I added a bounty) is related and gives the context and motivations (my GPLv3 MELT monitor on github; I added at last some README to it).
I am only interested in recent HTML5 compliant browsers (on GNU/Linux), e.g. Firefox 38 at least (and preferably 42) or Chrome 46 (on Debian/Sid desktop, x86-64)
So, suppose I have in my HTML5 page
<div id='myeditdiv' contenteditable='true'>
<span class='foo_cl'>FOO<span class='bar_cl'>bar</span></span>
</div>
(actually the HTML is generated, and so is the DOM; I'm currently generating on the server side some javascript which constructs the DOM; of course I can change the generators!)
And I am clicking so that the focus come between the two OO
. How can I get the DOM element of foo_cl
, preferably with Jquery.
Same question when focusing between ar
. I want the bar_cl
span.
Of course, $(':focus')
don't work. It gives the div
FWIW, it is commit 9109ae5b3d168f1 of the MELT monitor.
PS. See my (november 26th 2015) addenda to this question. Probably contenteditable
is not useful to me, but tabindex
surely is useful!