I've taken a look at the MutationObserver class from jQuery in order to achieve an effect that if a specific div becomes invisible that the focus is set to a specific input field.
Sadly this did not work as intended. The problem with that was that I'm making the visibility changed via CSS itself. Thus I have the following situation:
<div id="container">
.....
<div id="child">Test</div>
</div>
<input id="MyInputToFocusOn"/>
In the CSS on :hover over the container the child becomes visible. If there is no hover then the child becomes invisible (and instead an icon image also inside the container becomes visible).
This works quite well BUT as I mentioned I also need to set the focus via jquery as soon as the child becomes invisible. So far I did not find anything that could achieve this so my question is: Is there anything that could achieve this functionality?
Edit due to answers: I tried out the following:
$('#Container').mouseout(function () {
if ($('#Container')[0].currentStyle.visibility == "hidden") {
.....
}
});
The problem there is that it triggers BEFORE the CSS changes apply. Thus the visibility is still visible when the mouseout event fires.