Element removeAttribute() Method - Remove the href attribute from an <a> element: - Javascript DOM

Javascript examples for DOM:Element removeAttribute

Description

Element removeAttribute() Method - Remove the href attribute from an <a> element:

Demo Code

ResultView the demo in separate window

<!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  ww. j av a 2  s  .c o m
    document.getElementById("myAnchor").removeAttribute("href");
}
</script>

</body>
</html>

Related Tutorials