Is it possible to make an HTML anchor tag not clickable/linkable using CSS?

前端 未结 9 2162
故里飘歌
故里飘歌 2020-12-12 11:33

For example if I have this:

page link

Is there anything I can use for the style attribute that

9条回答
  •  时光取名叫无心
    2020-12-12 11:56

    A more un-obtrusive way (assuming you use jQuery):

    HTML:

    page link

    Javascript:

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

    The advantage of this is the clean separation between logic and presentation. If one day you decide that this link would do something else, you don't have to mess with the markup, just the JS.

提交回复
热议问题