jQuery mouseover与mouseenter的区别
2015-10-27 13:53
621 查看
在我们的页面中经常会用到mouseover与mouseout事件来给页面添加更好的渲染效果,但如果触发mouseover事件的元素有子元素的话,会造成闪烁的效果,看着很不舒服,这是因为mouseover与mouseout不论鼠标指针穿过被选元素或其子元素,都会触发。而mouseenter与mouseleave只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件。
<ul class="con-ul"> <li> <div class="con-one"> <div class="con-oneimg"> <img src="http://image123465.cn"> <div class="dask" style="display: block; opacity: 0;"></div> <div class="input" style="display: block; opacity: 0;"> <input type="button" class="inp inp-one" value="预览"> <input type="button" class="inp inp-two" value="使用"> </div> </div> <hr style="border-top:1px solid #b5b5b5;"> <p>study</p> </div> </li> </ul>
//1 $(".con-ul").on({ mouseenter: function() { $(this).find(".dask").stop(true,true).fadeIn(600); $(this).find(".input").stop(true,true).fadeIn(600); }, mouseleave: function() { $(this).find(".dask").stop(true,true).fadeOut(300); $(this).find(".input").stop(true,true).fadeOut(300); } }, ".con-oneimg"); //2 $(".con-ul").on({ mouseover: function() { $(this).find(".dask").stop(true,true).fadeIn(600); $(this).find(".input").stop(true,true).fadeIn(600); }, mouseout: function() { $(this).find(".dask").stop(true,true).fadeOut(300); $(this).find(".input").stop(true,true).fadeOut(300); } }, ".con-oneimg");
相关文章推荐
- jquery ajax的async属性的理解
- 基于jQuery的软键盘
- Jquery判断某个标签 Id是否存在
- jquery 做一个小的倒计时效果
- jquery 中js的总结问题
- 使用jQuery播放/暂停 HTML5视频
- jquery post json
- jQuery效果之页面窗口及jQuery插件开发
- Jquery选择器
- jQuery.noop
- jquery实现的V字形显示效果代码
- 基于Jquery+div+css实现弹出登录窗口(代码超简单)
- jquery操作HTML5 的data-*的用法实例分享
- jquery 评分插件
- jQuery效果之级联下拉框
- jquery each,click ,元素选择器
- jquery图文列表鼠标点击下拉显示文字说明内容
- jquery arguments
- 了解jQuery
- jQuery中$.get、$.post、$.getJSON和$.ajax的用法详解