JQuery slideToggle timeout

前端 未结 3 1306
盖世英雄少女心
盖世英雄少女心 2021-01-23 08:01

I have simple html page:





        
3条回答
  •  伪装坚强ぢ
    2021-01-23 08:28

    Check http://jsfiddle.net/XRYLk/3/

    I added mouseleave so in case the mouse was over it when first function fires up, it will set timer on mouseleave.

    jQuery:

        $("button").click(function() {
            $("div").slideToggle("slow");
        });
    
    setTimeout(hidepanel, 4000);
    
    function hidepanel(){
        if($('div').is(':hover') === false){ $('div').slideToggle(); }
    }
    
     $('div').mouseleave(function(){ setTimeout(hidepanel, 4000); });
    

提交回复
热议问题