Heim  >  Artikel  >  Web-Frontend  >  IE中鼠标经过option触发mouseout的解决方法_javascript技巧

IE中鼠标经过option触发mouseout的解决方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 16:17:201307Durchsuche

本文实例讲述了IE中鼠标经过option触发mouseout的解决方法。分享给大家供大家参考。具体分析如下:

要实现的功能:

有一个DIV,当鼠标经过时此DIV完全展开,当鼠标移开时DIV收缩回去,其中DIV里面有一个select选择框;

操作select的时候在IE中会出现一个问题,当鼠标经过option时,DIV会收缩回去,而在其他浏览器中无此现象。

解决的方法:

在IE中,当鼠标移到option时 window.event.toElement 的值为null,在其他浏览器中的值为object;

当鼠标直接从DIV中移出时 window.event.toElement 的值为object,其他浏览器也是;

综上,可以在mouseout中添加下面代码即可解决问题:

if (window.event.toElement == null) return;

希望本文所述对大家的javascript程序设计有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn