How to disable a link using only CSS?

前端 未结 22 3206
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 02:58

Is there any way to disable a link using CSS?

I have a class called current-page and want links with this class to be disabled so that no action occurs

22条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 03:31

    CSS can only be used to change the style of something. The best you could probably do with pure CSS is to hide the link altogether.

    What you really need is some javascript. Here's how you'd do what you want using the jQuery library.

    $('a.current-page').click(function() { return false; });
    

提交回复
热议问题