Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show menu after 2 seconds

Im trying having problems on showing a <div> after 2 seconds.. My problem is that when i hover the button, the menu is displayed with no delay, and i want a delay of 2 secs...

Try to hover: Mere på cabiweb, then the menu will display -> You can see it here

The code :

<script>$(document).ready(function() { 
    $("#dropdown").hover(function(){
        $(".drop-inner").delay(2000).show();
      });
    });</script>

1 Answers

Use a timeout rather than .delay(), the latter only affects queued functions (such as effects):

$("#dropdown").hover(function() {
    setTimeout(function() {
        $(".drop-inner").show();
    }, 2000);
});
like image 129
Alnitak Avatar answered Nov 18 '25 20:11

Alnitak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!