Is there any way to disable a link using CSS?
If you have a class called current-page and want links with this class to be disabled so that no action occurs when they are clicked.
- CSS can only be used to change the style. The best way you could probably do with CSS is to hide the link altogether.
- What you really need is some javascript. Here’s how can you do the javascript function and what you want using the jQuery library.
- $(‘a.current-page’).click(function() { return false; });
CSS can’t do that because it is only for presentation.
Your options are:
- Don’t include the href attribute in your tags.
- Use JavaScript, to find the anchor elements with that class, and remove their href or onclick attributes accordingly.
- jQuery would help you with that problem(NickF showed how to do something similar but better).
Here the solution for Bootstrap Disabled Link and Bootstrap Disabled Button.
Bootstrap Disabled Link
[pastacode lang=”markup” manual=”%3Ca%20href%3D%22%23%22%20class%3D%22btn%20btn-primary%20btn-lg%20disabled%22%20role%3D%22button%22%3EPrimary%20link%3C%2Fa%3E%0A%3Ca%20href%3D%22%23%22%20class%3D%22btn%20btn-default%20btn-lg%20disabled%22%20role%3D%22button%22%3ELink%3C%2Fa%3E%0A” message=”HTML Code” highlight=”” provider=”manual”/] [ad type=”banner”]Bootstrap Disabled Button but it looks like link
[pastacode lang=”markup” manual=”%3Cbutton%20type%3D%22button%22%20class%3D%22btn%20btn-link%22%3ELink%3C%2Fbutton%3E%0A” message=”HTML Code” highlight=”” provider=”manual”/]