I have the below which disables all hyperlinks but after an event I want to enable them back all again, how can I do this?
$("a").click(function() { return false; });
I don't think its as simple as just setting it to true. ;)
Thanks all
I have the below which disables all hyperlinks but after an event I want to enable them back all again, how can I do this?
$("a").click(function() { return false; });
I don't think its as simple as just setting it to true. ;)
Thanks all
to restore:
Instead of binding your "click" handler that way, do this:
Then when you want to remove that handler it's easy:
That way you avoid messing up other stuff that might be bound to "click". If you just unbind "click", you unbind everything bound to that event.
edit in 2014 — the way you bind events now is with
.on()
:Probably it'd be better to do this:
To unbind:
Finally, you could bind a handler to the document body and deal with
<a>
tags that are dynamically added:Or even better, simply toggle the
display
of a large element with the highz-index
. In the example below, the div covers the body.You want to unbind the event: http://api.jquery.com/unbind/
You should be able to unbind it.