On Fri, Oct 23, 2009 at 12:02 AM, TH Lim <ssh...@gmail.com> wrote: > > Hi, > > I used toggleClass method to toggle the colors of my message when the > user clicks a button. toggleClass() worked well if I didn't specify > any duration i.e. instanteous switch from white background to red > background. The problem arises when I added a duration of ,say, 2s. If > the user clicked the button before the message has reached the final > state (say the user clicked the button 1s after the 1st click), > clicking the button will not revert the message to its original state > i.e. white background. How do I fix this? >
!$("#console").is(":animated") && $("#console").toggleClass('red', 2000); This will cause the click that occurs during the animation to do nothing, but will prevent your element from getting into a state where it can no longer be toggle with a duration. If you have any further questions about jQuery UI Effects, please post to the jQuery UI list: http://groups.google.com/group/jquery-ui Thanks. - Richard