How to Disable Link in JavaScript?

In this tutorial, I will tell you how to disable link using javascript. As there are many ways to disable hyperlink like we can use event handler, getelmentbyid and set attribute method which is used to get and set value, attribute on any  HTML element. So, following are the ways to stop the link functionality.

How to Disable Link in JavaScript?

Method 1: Using CSS

To disable hyperlink the main CSS property that we use is pointer events. Check the code given below.

index.html

Method 2: Using Function

Method 3: Using Event Handler

Event handler used to handle any action like inputting data, calling methods etc.

Example:

You can replace # (hash) with javascript:void (0) event handler.

Comment down below if you have queries or know any other way to disable hyperlink in javascript.

One thought on “How to Disable Link in JavaScript?

Leave a Reply

Your email address will not be published. Required fields are marked *