I am trying to have a function done to all links on a page and then have the function undone if a condition is met.
$('a').click(function(){
//some function
if ( /*some condition*/ ) {
$(this).//undo above function
}
});
Note: I am not trying to use unbind(), I am trying to have the function undo itself. I apologize in advance if this is a bit unclear – please ask me anything you are unsure about. Thanks.
Have you tried:
Edit: There is another way that is fairly common that didn’t really occur to me at first. Since you’re doing this to all of your
<a>tags, you can use thedelegateandundelegatefunctions to register the event. In more modern versions of jquery this is done with the.onand.offmethods:http://api.jquery.com/delegate/
http://api.jquery.com/undelegate/
http://api.jquery.com/on/
http://api.jquery.com/off/