jQuery disable a link

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

    Try this:

    $("a").removeAttr('href');
    

    EDIT-

    From your updated code:

     var location= $('#link1').attr("href");
     $("#link1").removeAttr('href');
     $('ul').addClass('expanded');
     $('ul.expanded').fadeIn(300);
     $("#link1").attr("href", location);
    

提交回复
热议问题