<a href="gohere.aspx" class="my-link">Click me</a>
I did
$('.my-link').attr('disabled', true);
but it didn't work
Is there an easy way to disable the hyperlink using jquery? Remove href? I would rather not fiddle with href. So if I can do it w/o removing href, that would be great.
You can bind a click handler that returns false:
To re-enable it again, unbind the handler:
Note that
disableddoesn't work because it is designed for form inputs only.jQuery has anticipated this already, providing a shortcut as of jQuery 1.4.3:
And to unbind / re-enable: