jQuery disable a link

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

    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') {
            e.preventDefault();
        }
    });
    

    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:

    Google
    

    And now you CAN use disabled property for links

    Cheers!

提交回复
热议问题