Javascript examples for DOM:Element removeAttribute
The removeAttribute() method removes attribute by name.
Parameter | Type | Description |
---|---|---|
attributename | String | Required. The name of the attribute |
No return value
The following code shows how to Remove the href attribute from element:
<!DOCTYPE html> <html> <body> <a id="myAnchor" href="http://www.java2s.com">A Link: go to java2s.com</a> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w w w . ja va2 s . com var elmnt = document.getElementById("myAnchor"); elmnt.removeAttribute("href"); } </script> </body> </html>