jQuery disable a link

前端 未结 17 1438
半阙折子戏
半阙折子戏 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:24

    Just set preventDefault and return false

       $('#your-identifier').click(function(e) {
            e.preventDefault();
            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');
    

提交回复
热议问题