sudhakarinfotech
(current)
Run Code
Live Code Editor- jQuery removeAttr() Method
Source Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> jQuery removeAttr Method </title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> </script> <style type="text/css"> .btn{ padding:10px 15px; background-color:black; color:white; border:none; display:block; margin-top:50px; } p{ height:50px; background-color:lightgrey; font-size:20px; padding:10px; } </style> <script> $(document).ready(function(){ // Removes the hyperlink's href attribute $("button").click(function(){ $("a").removeAttr("href"); }); }); </script> </head> <body> <h1> jQuery removeAttr Method </h1> <a href="https://www.google.com">This will not work after button click</a> <button class="btn">Click To Remove Attribute</button> </body> </html>
Source Code Output :
Running