html select控件移动到option标签时就触发mouseleave()解决方法
2018-01-27 17:11
411 查看
今天在做select标签鼠标移出时就自动隐藏的功能,在谷歌下面调试没问题,但是到火狐上调试时发现鼠标下移到option标签时就会触发mouseleave方法,百度了之后找到问题的方法,就是在mouseleave方法中加入一个事件对象,通过判断鼠标移动到的对象是否为null或undefined(移动到option标签上ie下为null,firefox等为undefined)。
代码:
代码:
$(xxx).mouseleave(function (e) { var o = e.relatedTarget || e.toElement;//获取select标签对象,移动到option上谷歌貌似option在mouseleave函数上是与select绑定在一起的不会触发mouseleave事件,ie下是null,firefox等为undefined if (!o) return; //增加移动到的对象判断,o为null或者undefined时(即移动到option时)return,不执行下面的方法 //执行你的代码 });
相关文章推荐
- 解决方案:c#鼠标离开到子控件也触发MouseLeave事件的解决方法
- easyui datebox控件点击今天按钮不触发onSelect事件的解决方法
- IE的option标签单击事件无法触发的解决方法
- jquery html动态生成select标签出问题的解决方法
- 解决HTML SELECT控件 disabled 后无法向后台传值的方法
- 解决HTML select控件 disabled 后无法向后台传值的方法
- 解决HTML select控件 设置属性 disabled 后无法向后台传值的方法
- 快速移动鼠标触发问题及解决方法(ECharts外部调用保存为图片操作及工作流接线mouseenter和mouseleave)
- 解决HTML select控件 设置属性 disabled 后无法向后台传值的方法
- HtmlAgilityPack不能解析option标签的解决方法
- jquery html动态生成select标签出问题的解决方法
- IE的option标签单击事件无法触发的解决方法
- ie6.0中关于动态改变html中select标签中option的处理方法
- IE6、7下html标签间存在空白符,导致渲染后占用多余空白位置的原因及解决方法
- HTML select标签 获取选中的option的value及Text内容
- [Phonegap+Sencha Touch] 移动开发26 Android下的sencha touch程序,转屏时,Ext.Viewport不能触发orientationchange事件的解决的方法
- 用HTML的select+option标签实现下拉框
- win7 下完美解决VB 动态添加的flash 控件 fscommand 消息未触发的方法
- jquery window 窗口被select控件遮挡的解决方法
- A标签触发onclick事件而不跳转的多种解决方法