<html>
<body>
<a id="myAnchor">A Link: Go to w3schools.com</a>
<p>Click the button to create a "class" attribute with the value "www.w3schools.com" and insert it to the a element above.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var anchor = document.getElementById("myAnchor");
var att = document.createAttribute("href");
att.value = "../index.html";
anchor.setAttributeNode(att);
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_createattribute2 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:01:40 GMT -->
</html>