I need a JavaScript method to detect when the mouse leaves an element with id="myDiv"
within an if()
statement.
I cannot use the JS onmouseout
event embedded in my HTML. I must be able to detect onmouseout
inside an if()
statement if at all possible.
Here is the basic syntax I was thinking of, but it doesn't make sense as is (and hasn't been working):
if(document.getElementById("myDiv").onmouseout) // if mouse leaves <div id="myDiv">
{
//code to be executed
}
I prefer legit "Google Gadget JavaScript", which may be slightly different, but if you know of a JavaScript solution, you're welcome to share it!
It should be used like this:
document.getElementById("myDiv").onmouseout = function(){
//code to be executed
}