在我们的页面中经常会用到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事件中mouseover与mouseenter的区别的详细内容,更多请关注php中文网其它相关文章!
                        
                        每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号