Remove the href attribute node from an <a> element:
<!DOCTYPE html> <html> <body> <a id="myAnchor" href="https://www.java2s.com">A Link: Go to java2s.com</a> <p id="demo">Click the button to remove the href attribute node from the a element.</p> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from www . j a va 2 s . co m var elmnt = document.getElementById("myAnchor"); var attr = elmnt.getAttributeNode("href"); elmnt.removeAttributeNode(attr); } </script> </body> </html>