Disabled href tag

Disabled href tag

Although that link is disabled, it’s still clickable.

Can I make it not-clickable if it’s disabled? Should I use JavaScript necessarily?


Solution 1:

There is no disabled attribute for hyperlinks. If you don’t want something to be linked then you’ll need to remove the <a> tag altogether, or remove its href attribute.

Solution 2:

With the help of css you will disable the hyperlink. Try the below

a.disabled {
  pointer-events: none;
  cursor: default;
<a href="link.html" class="disabled">Link</a>

Solution 3:

You can use:

<a href="/" onclick="return false;">123n</a>

Solution 4:

You can use one of these solutions:




<a href="javascript:function() { return false; }">link</a>
<a href="/" onclick="return false;">link</a>


<a href="www.page.com" disabled="disabled">link</a>

<style type="text/css">
    a[disabled="disabled"] {
        pointer-events: none;

Solution 5:

Try this:

<a href="javascript:void(0)" style="cursor: default;">123n</a>

Solution 6:

The <a> tag doesn’t have a disabled attribute, that’s just for <input>s (and <select>s and <textarea>s).

To “disable” a link, you can remove its href attribute, or add a click handler that returns false.

Related:  Why are .call and .apply slower than a direct function call in JavaScript?