[jquery] jQuery disable a link

Anyone know how to disable a link in jquery WITHOUT using return false;?

Specifically, what I'm trying to do is disable the link of an item, performing a click on it using jquery which triggers some stuff, then re-enabling that link so that if it's clicked again it works as default.

Thanks. Dave

UPDATE Here's the code. What it needs to do after the .expanded class has been applied is to re-enable the disabled link.

$('ul li').click(function(e) {
    //return false;

This question is related to jquery hyperlink

The answer is

html link example:

        <!-- boostrap button + fontawesome icon -->
        <a class="btn btn-primary" id="BT_Download" target="_blank" href="DownloadDoc?Id=32">
        <i class="icon-file-text icon-large"></i>
        Download Document

use this in jQuery


add this to css :

    a[disabled="disabled"] {
        pointer-events: none;

You should find you answer here.

Thanks @Will and @Matt for this elegant solution.

jQuery('#path .to .your a').each(function(){
    var $t = jQuery(this);

This works for links that have the onclick attribute set inline. This also allows you to later remove the "return false" in order to enable it.

        //disable all links matching class
        $('.yourLinkClass').each(function(index) {
            var link = $(this);
            var OnClickValue = link.attr("onclick");
            link.attr("onclick", "return false; " + OnClickValue);

        //enable all edit links
        $('.yourLinkClass').each(function (index) {
            var link = $(this);
            var OnClickValue = link.attr("onclick");
            link.attr("onclick", OnClickValue.replace("return false; ", ""));

unbind() was deprecated in jQuery 3, use the off() method instead:


you can just hide and show the link as you like


For others who came here via google like me - here's another approach:

.disabled {
  color: grey; // ...whatever

$('#myLink').click(function (e) {
  if ($(this).hasClass('disabled'))
    return false; // Do something else in here if required
    window.location.href = $(this).attr('href');

// Elsewhere in your code
if (disabledCondition == true)

Remember: not only this is a css class


but also these two

class="buttonstyle disabled"

so you can easily add and remove further classes with jQuery. No need to touch href...

I love jQuery! ;-)

Just set preventDefault and return false

   $('#your-identifier').click(function(e) {
        return false;

This will be disabled link but still, you will see a clickable icon(hand) icon. You can remove that too with below

$('#your-identifier').css('cursor', 'auto');

Just trigger stuff, set some flag, return false. If flag is set - do nothing.

If you go the href route, you can save it

To disable:

    $(this).data("href", $(this).attr("href")).removeAttr("href");

Then re-enable using:

    $(this).attr("href", $(this).data("href"));

In one case I had to do it this way because the click events were already bound somewhere else and I had no control over it.

Here is an alternate css/jQuery solution that I prefer for its terseness and minimized scripting:


a.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: default;


$('.disableAfterClick').click(function (e) {

I know this isn't with jQuery but you can disable a link with some simple css:

a[disabled] {
  z-index: -1;

the HTML would look like

<a disabled="disabled" href="/start">Take Survey</a>

Just use $("a").prop("disabled", true);. This will really disable de link element. Needs to be prop("disabled", true). Don't use attr("disabled", true)

My fav in "checkout to edit an item and prevent -wild wild west clicks to anywhere- while in a checkout" functions

$('a').click(function(e) {
    var = $(this).attr('disabled');
    if (var === 'disabled') {

So if i want that all external links in a second action toolbar should be disabled while in the "edit-mode" as described above, i'll add in the edit function

$('#actionToolbar .external').attr('disabled', true);

Link example after fire:

<a href="http://goo.gl" target="elsewhere" class="external" disabled="disabled">Google</a>

And now you CAN use disabled property for links


I always use this in jQuery for disabling links

$("form a").attr("disabled", "disabled");

You can remove click for link by following;


You can re-enable link by followings,


You can not use 'disabled' property for links.

Try this:



From your updated code:

 var location= $('#link1').attr("href");
 $("#link1").attr("href", location);