We help IT Professionals succeed at work.

jQuer: avoid user double-clicking button fast to duplicate animation

Brad Bansner
Brad Bansner asked
on
Here is my screen:

http://www.genspangroup.com/survey/index.asp?id=HBEYBTW4SS&surveyid=1

When you click the Previous or Next buttons, the attached code does a fadeOut and a fadeIn of the various questions. If you click the Next button twice, very quickly, you get something like the attached screenshot.

I put stop() commands in, thinking it would solve this problem, but apparently it does not. Or maybe I am not using stop() correctly? Thanks!
$('#question'+currentQuestion).stop().fadeOut(200, function(){

//other Javascript

	$('#question'+newQuestion).stop().fadeIn(800);
});

Open in new window

1.jpg
Comment
Watch Question

Commented:
Disable the button when it gets clicked and enable it when the question is loaded.
Brad BansnerWeb Developer

Author

Commented:
Ah, of course. Simple and fixes it.