sat
sat

Reputation: 1009

stop build up of clicks with jquery toggle

I have a little query, when I click on the image to toggle the navigation multiple times really fastly it builds up a que of clicks that go on by themselves, its really annoying and I can't figure out how to stop it as the jquery .stop isn't working.

here is the url

http://satbulsara.com/tests/

here is my code

$('img').toggle(function() { 
          $('ul').fadeIn("slow");
           },
           function() { 
           $('ul').fadeOut("slow"); 
           });  

Upvotes: 1

Views: 784

Answers (1)

Frédéric Hamidi
Frédéric Hamidi

Reputation: 262939

You can use the stop() method to clear the animation queue and stop the current effect before queuing a new one:

$('img').toggle(function() { 
    $('ul').stop(true, true).fadeIn("slow");
}, function() { 
    $('ul').stop(true, true).fadeOut("slow"); 
});  

Upvotes: 3

Related Questions