Is there any way to know when any child element is in focus? My problem revolves around the example below where I need a div not to blur when a child element is in focus (in this case any input element that serves for user interaction activates the onblur
of the div):
(function divShow(){
var div = document.getElementsByTagName('div');
div.classList.toggle('active');
div.addEventListener('blur', function(){
div.classList.toggle('active');
}, true);
})();
div {display: none}
div.active {display: block}
<div tabindex="-1">
<header>My Tytle</header>
<content>Hello world!!!</content>
<footer>
<button>My button</button>
</footer>
</div>
I can identify when a first-level element is in focus and possibly make a if
for the blur action, but I think there is a more useful way of handling that.
help?