Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery using stop() with hide()/show()?

Tags:

jquery

I wonder if it's somehow possible to use the stop() function (I normally use on animate()) with hide() or show().

if I quickly hover repeatedly over a div which uses show() to display some subdivs the show-animation repeats over and over again. The stop() function would stop that behaviour.

However I've no clue how I can use the stop() function with hide() or show().

Is that even possible?

Thank you
Regards Matt

like image 630
matt Avatar asked Jul 01 '10 07:07

matt


1 Answers

You have to set a duration for your show / hide effect:

.hide('slow')

After that you are able to use .stop() and .stop(true,true)

stop( [ clearQueue ], [ jumpToEnd ] )

clearQueue A Boolean indicating whether to remove queued animation as well. Defaults to false.

jumpToEnd A Boolean indicating whether to complete the current animation immediately. Defaults to false.

Another approach would be to add an delay like

 .delay(500).hide(1);

http://api.jquery.com/delay/

.delay( duration, [ queueName ] ) duration An integer indicating the number of milliseconds to delay execution of the next item in the queue.

queueName A string containing the name of the queue. Defaults to fx, the standard effects queue.

like image 123
jantimon Avatar answered Oct 09 '22 07:10

jantimon