Possible Duplicate:
.delay() and .setTimeout()
Is there a way to break and stop javascript delay here ?
I want user when click on button this delay will stop and not execute the expected code like here
$(#my_id).html('write my string here').delay(12000).fadeOut(1000) ;
so how can this be stopped to not fadeOut my string when user click on button with id 'my_button' ?
any help is much appreciated
As documentation for jQuery.delay clearly states, you can’t cancel delay configured using that function.
Use regular javascript setTimeout to achive easily cancellable actions. For example your code could be transformed into: