How do you make an anchor link non-clickable or disabled?

后端 未结 18 2151
清酒与你
清酒与你 2020-11-27 02:38

I have an anchor link that I want to disable once the user clicks on it. Or, remove the anchor tag from around the text, but definitely keep the text.



        
18条回答
  •  我在风中等你
    2020-11-27 03:08

    Use pointer-events CSS style. (as Jason MacDonald suggested)

    See MDN https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events. Its supported in most browsers.

    Simple adding "disabled" attribute to anchor will do the job if you have global CSS rule like following:

    a[disabled], a[disabled]:hover {
       pointer-events: none;
       color: #e1e1e1;
    }
    

提交回复
热议问题