How to make an anchor tag refer to nothing?

后端 未结 18 1719
一向
一向 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 10:40

    I know this is an old question, but I thought I'd add my two cents anyway:

    It depends on what the link is going to do, but usually, I would be pointing the link at a url that could possibly be displaying/doing the same thing, for example, if you're making a little about box pop up:

    About
    

    Then with jQuery

    $('#about').click(function(e) {
        $('#aboutbox').show();
        e.preventDefault();
    });
    

    This way, very old browsers (or browsers with JavaScript disabled) can still navigate to a separate about page, but more importantly, Google will also pick this up and crawl the contents of the about page.

提交回复
热议问题