Remove the href attribute from an <a> element:
document.getElementById("myAnchor").removeAttribute("href");
<!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 from the a element.</p> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w w w. j a va 2s .c o m document.getElementById("myAnchor").removeAttribute("href"); } </script> </body> </html>