欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery插件實(shí)現(xiàn)鼠標(biāo)隱藏

 更新時(shí)間:2021年05月14日 08:22:53   作者:阿飛超努力  
這篇文章主要為大家詳細(xì)介紹了jquery插件實(shí)現(xiàn)鼠標(biāo)隱藏,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了jquery插件實(shí)現(xiàn)鼠標(biāo)隱藏的具體代碼,供大家參考,具體內(nèi)容如下

鼠標(biāo)懸浮在某個(gè)dom上的時(shí)候,自動(dòng)給你隱藏,效果圖因?yàn)殇浧淋浖膯?wèn)題,作用不出來(lái)

效果如下

代碼部分

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <title>做久置隱藏</title>
  <script src="js/jquery-3.4.1.min.js"></script>
  <style>
   *{
    margin: 0;
    padding: 0;
   }
   .box{
    border: 1px solid lightgray;
    width: 100px;
    height: 100px;
    margin: 10px;
    float: left;
   }
  </style>
 </head>
 <body>
  <div class="box" id="box1" style="background-color: #1abc9c;"></div>
  <div class="box" id="box2" style="background-color: #3498db;"></div>
  <div class="box" id="box3" style="background-color: #f1c40f;"></div>
  <div class="box" id="box4" style="background-color: #e74c3c;"></div>
  <div class="box" id="box5" style="background-color: #9b59b6;"></div>
 </body>
</html>
<script>
 $(function(){
  $.mh(["#box1","#box3","#box5"]);
  
  
  
 })
 $.extend({
  mh:function(op,time){
   op=op==undefined?[]:op;//對(duì)象
   time = time==undefined?500:time;//多久隱藏
   var str = op.join(',');
   var t = null;
   var f = false;
   $(str).mouseenter(function(){
    f = true;
    $(str).css('cursor','default');
   }).mouseleave(function(){
    f = false;
    clearTimeout(t);
    $(str).css('cursor','default');
   }).mousemove(function(){
    if(f){
     $(str).css('cursor','default');
     clearTimeout(t);
     hid();
    }else{
     clearTimeout(t);
    }
   })
   function hid(){
    t =setTimeout(function(){
     $(str).css('cursor','none');
     console.log('隱藏了');
    },time)
   }
  }
 })
</script>

思路解釋

  • 把所有動(dòng)作考慮進(jìn)去,只要鼠標(biāo)符合我們的判斷,給一個(gè)樣式cursor:none就完事
  • 此外就是給上cursor:default還原默認(rèn)樣式了

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論