zoukankan      html  css  js  c++  java
  • jQuery mouseover与mouseenter的区别

    在我们的页面中经常会用到mouseover与mouseout事件来给页面添加更好的渲染效果,但如果触发mouseover事件的元素有子元素的话,会造成闪烁的效果,看着很不舒服,这是因为mouseover与mouseout不论鼠标指针穿过被选元素或其子元素,都会触发。而mouseenter与mouseleave只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件。

     1 <ul class="con-ul">
     2     <li>
     3         <div class="con-one">
     4             <div class="con-oneimg">
     5                 <img src="http://image123465.cn">
     6             <div class="dask" style="display: block; opacity: 0;"></div>
     7             <div class="input" style="display: block; opacity: 0;">
     8                 <input type="button" class="inp inp-one" value="预览">
     9                 <input type="button" class="inp inp-two" value="使用">
    10             </div>
    11             </div>
    12         <hr style="border-top:1px solid #b5b5b5;">
    13         <p>study</p>
    14         </div>
    15     </li>
    16 </ul>
     1 //1
     2 $(".con-ul").on({
     3         mouseenter: function() {
     4             $(this).find(".dask").stop(true,true).fadeIn(600);
     5             $(this).find(".input").stop(true,true).fadeIn(600);
     6         },
     7         mouseleave: function() {
     8             $(this).find(".dask").stop(true,true).fadeOut(300);
     9             $(this).find(".input").stop(true,true).fadeOut(300);
    10         }
    11     }, ".con-oneimg");
    12 
    13 //2
    14 $(".con-ul").on({
    15         mouseover: function() {
    16             $(this).find(".dask").stop(true,true).fadeIn(600);
    17             $(this).find(".input").stop(true,true).fadeIn(600);
    18         },
    19         mouseout: function() {
    20             $(this).find(".dask").stop(true,true).fadeOut(300);
    21             $(this).find(".input").stop(true,true).fadeOut(300);
    22         }
    23     }, ".con-oneimg");
  • 相关阅读:
    linux下解除端口占用
    设计模式(二)观察者模式
    设计模式(一) 策略模式
    loj #6235. 区间素数个数
    loj #2013. 「SCOI2016」幸运数字
    loj #6014. 「网络流 24 题」最长 k 可重区间集
    loj #6013. 「网络流 24 题」负载平衡
    loj #2255. 「SNOI2017」炸弹
    loj #2051. 「HNOI2016」序列
    loj #6122. 「网络流 24 题」航空路线问题
  • 原文地址:https://www.cnblogs.com/dengmj/p/4913996.html
Copyright © 2011-2022 走看看