Tutorial :jQuery accordion can't disable click when still animating?


I've attempting to develop a jQuery accordion, which is work ing pretty well so far considering I don't really know jQuery.

The main problem i have is if you click about quite quickly on different sections it will eventially knock the whole accordion out for a short time which wouldn't be good enough really.

I attempted to put

if ($("#accordion ul li").is(':animated')) {

around the click function but didn't seem to do anything, could anyone give me a helping hand or tell me if it is at least possible?

Also you will notice that when clicked on, the right side of the accordion shrinks a little, is this fixable or just something i'll have to put up with?

You can view what i mean here http://dev.boomeranginternet.co.uk/accordion/accordion1.asp

Thanks in advance for any help.

Regards, J.


by putting around the click function you mean like this?

    if ($("#accordion ul li").is(":animated")) {         } else {          $("#accordion ul li").click(function() {              // do animation          }):      }  

thats the wrong way around, the click function defines an event handler. if you want your animation to only run as long as no other animation is running you must check inside your event handler e.g.

$("#accordion ul li").click(function() {      if ($("#accordion ul li").is(":not(animated)")) {           // do animation      }  }):  


Try something like this insted:

$("#accordion ul li").click(function(){      if ($(':animated').length) {          return false;      }        //Your code goes here...  });  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »