disable a hyperlink using jQuery

后端 未结 11 1673
悲&欢浪女
悲&欢浪女 2020-11-29 02:06
Click me

I did

$(\'.my-link\').attr(\'disabled\', true);
11条回答
  •  独厮守ぢ
    2020-11-29 02:38

    $('.my-link').click(function(e) { e.preventDefault(); }); 
    

    You could use:

    $('.my-link').click(function(e) { return false; }); 
    

    But I don't like to use this myself as it is more cryptic, even though it is used extensively throughout much jQuery code.

提交回复
热议问题