Home >Web Front-end >JS Tutorial >Solution to the problem of mouseout triggered by mouse passing option in IE_javascript skills
The example in this article describes the solution to the problem of triggering mouseout when the mouse passes the option in IE. Share it with everyone for your reference. The specific analysis is as follows:
Function to be implemented:
There is a DIV. When the mouse passes over the DIV, it is fully expanded. When the mouse is removed, the DIV shrinks back. There is a select box inside the DIV;
A problem will occur in IE when operating select. When the mouse passes over the option, the DIV will shrink back, but this phenomenon does not occur in other browsers.
Solution:
In IE, when the mouse moves to option, the value of window.event.toElement is null, and in other browsers, the value is object;
When the mouse is moved directly out of the DIV, the value of window.event.toElement is object, as are other browsers;
To sum up, you can add the following code to mouseout to solve the problem:
if (window.event.toElement == null) return;
I hope this article will be helpful to everyone’s JavaScript programming design.