jQuery disable a link

前端 未结 17 1368
半阙折子戏
半阙折子戏 2020-11-22 14:45

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

17条回答
  •  臣服心动
    2020-11-22 15:30

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

    css:

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

    jQuery:

    $('.disableAfterClick').click(function (e) {
       $(this).addClass('disabled');
    });
    

提交回复
热议问题