jQuery mouseover与mouseenter的区别
2024-09-21 06:53:11
在我们的页面中经常会用到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>
//
$(".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"); //
$(".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");
最新文章
- JavaScript操作Cookie
- js鼠标滚轮滚动图片切换效果
- [Architecture Pattern] Factory Builder
- 使用inno setup打包程序完整脚本(.net框架检测,重复安装检测)
- discuz X2.5自己写代码,获取当前登录的用户信息
- 【转】Enable ARC in a Cocos2D Project: The Step-by-Step-How-To-Guide Woof-Woof!
- SQL server概述
- 使用libcurl提交POST请求
- iOS特性
- linux下使用gcc编译运行C程序
- Mybatis Generator生成Mybatis Dao接口层*Mapper.xml以及对应实体类
- SVN的安装和配置
- Flask 学习 七 用户认证
- python接口自动化-post请求2
- php单例模式的实例
- 【BZOJ1930】【SHOI2003】吃豆豆
- bash脚本:集群资源争夺战crazy-killer
- 理解JVM——JVM的结构
- SP_attach_db 添加数据库文件
- python3 requests 进行接口测试、爬虫使用总结