Ans: To remove clickable behavior from a link use jQuery removeAttr() method.

This method removes any specified HTML attribute. Following example demonstrate the removeAttr() method uses.

<!--
Used basic html and bootstrap skeleton from the below link for style purpose which contains bootstrap.css,bootstrap.js,jquery.js
https://www.w3schools.com/bootstrap/bootstrap_get_started.asp
-->
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>How to remove the clickable behavior from a link using jQuery</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">        
    </head>
    <body>
        <div class="container" style="max-width:800px;margin:0 auto;margin-top:50px;">  
            <div>
                <h2 style="margin-bottom:50px;">Live Demo: How to remove the clickable behavior from a link using jQuery</h2>              
            </div>
            <div>
                <button type="button" class="remove-href btn btn-success">Remove clickable Href</button>   
            </div>
            <div style="margin-top:20px;">
                <a href="http://www.tutorialsmint.com" class="web-link">Tutorialsmint.com</a>
            </div>
            <div style="margin-top:20px;" class="attr-added-msg"></div>
        </div>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script>
            $(document).ready(function () {
                $(".remove-href").click(function () {
                    $(".web-link").removeAttr('href');
                });
            });
        </script>
    </body>
</html>

On clicking Remove clickable Href button it removes the href to the web-link class.
Written by
Check out this Author's contributed articles.
If you like Tutorialsmint and would like to contribute, you can also write an article using Write an Article. See your article appearing on the Tutorialsmint main page and help other programmers to enhance their knowledge.

Comments(0)

RECENT TUTORIALS
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Edit Post
Add Reply