How Can I Disable  an HTML Anchor Tag?

Posted by

This tutorial focuses on using javascript to disable the anchor tag in HTML. You’ll discover how to make a tag in HTML inactive. We’ll assist you by providing an example of how to disable a JavaScript element. The process of disabling a tag in jQuery is covered in detail in this article. The steps to disable an anchor tag in jQuery are listed below.

I’ll show you several examples of how to use javascript, jquery, and CSS to disable anchor tags if you want to do that.

Now, let’s look at a few straightforward examples that will show you how to remove a tag href in HTML below.

Example 1:

<!DOCTYPE html>
<html>
<head>
    <title>How to Disable a Anchor Tag in HTML? </title>
    <style type="text/css">
        a.disabled {
          pointer-events: none;
          cursor: default;
          opacity: .6;
        }
    </style>
</head>
<body>
  
<h1>How to Disable a Anchor Tag in HTML? </h1>
  
<a href="https://www.itsolutionstuff.com" class="disabled">Go to ItSolutionStuff.com</a>
  
</body>
</html>

Example 2:

<!DOCTYPE html>
<html>
<head>
    <title>How to Disable a Anchor Tag in HTML? </title>
</head>
<body>
  
<h1>How to Disable a Anchor Tag in HTML? </h1>
  
<a href="https://www.itsolutionstuff.com" onclick="return false;">Go to ItSolutionStuff.com</a>
  
</body>
</html>

Example 3:

<!DOCTYPE html>
<html>
<head>
    <title>How to Disable a Anchor Tag in HTML?</title>
</head>
<body>
  
<h1>How to Disable a Anchor Tag in HTML?</h1>
  
<a href="javascript:function() { return false; }">Go to ItSolutionStuff.com</a>
  
</body>
</html>

Example 4:

<!DOCTYPE html>
<html>
<head>
    <title>How to Disable a Anchor Tag in HTML? </title>
    <style type="text/css">
        a[disabled="disabled"] {
            pointer-events: none;
        }
    </style>
</head>
<body>
  
<h1>How to Disable a Anchor Tag in HTML? </h1>
  
<a href="https://www.itsolutionstuff.com" disabled="disabled">Go to ItSolutionStuff.com</a>
  
</body>
</html>
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x