Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <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], Fri, 23 Jan 2015 08:10:37 GMT --> </html>
Result:
Try it Yourself - © w3schools.com