How to make an anchor tag refer to nothing?

后端 未结 18 1726
一向
一向 2020-12-12 10:28

I use jQuery, I need to make some anchor tags perform no action.

I usually write it like this:

link

H

18条回答
  •  不知归路
    2020-12-12 11:01

    The correct way to handle this is to "break" the link with jQuery when you handle the link

    HTML

    My Link
    

    JS

    $('#theLink').click(function(ev){
        // do whatever you want here
    
        ev.preventDefault();
        ev.stopPropagation();
    });
    

    Those final two calls stop the browser interpreting the click.

提交回复
热议问题