I want to bind focus() event only to children of divs with certain class. This is what I tried and didn't work:
var boxedElements = "p,div,h1,h2,h3,h4,h5,h6,table";
$(".myBox").find(boxedElements).focus(function () {
var tagname = $(this).prop("tagName");
console.log(tagname);
});
The function is never reached for some reason. Any ideas of how to approach this?
Edit
<div class="myBox" contenteditable="true">
<h3>This is a header</h3>
<p>This is a paragraph</p>
<p>This is another paragraph</p>
</div>
Now the user can either click on of the elements or, since its contenteditable, can navigate using the keyboard arrows from h3 to the the first p element for example. I want to be able to detect that.