<html>
<body>
<h1>The Element Object</h1>
<h2>The setAttribute() Method</h2>
<a id="myAnchor">Go to w3schools.com</a>
<p>Click "add" to add an href attribute to the element above.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("myAnchor").setAttribute("href", "../index.html");
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_setattribute2 by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:39:46 GMT -->
</html>