You're trying to remove an event, because that's what .unbind
does. (Also, your syntax for .unbind
is not supported, but it's not what you're after anyway.) Instead, just check inside pulse
whether or not to continue fading. This works because pulse
is called recursively, so the check is done each time a fade iteration has stopped:
function pulse(){
if(clicked) {
playbtn.delay(200).fadeOut('slow').delay(50).fadeIn('slow', pulse);
}
}