Tryit Editor v1.4

<html> <head> <script type="text/javascript"> function changeLink() { document.getElementById('myAnchor').innerHTML="Visit W3Schools"; document.getElementById('myAnchor').href="../default.htm"; document.getElementById('myAnchor').target="_blank"; } </script> </head> <body> <a id="myAnchor" href="../../www.microsoft.com/default.htm">Visit Microsoft</a> <input type="button" onclick="changeLink()" value="Change link"> <p>In this example we change the text and the URL of a hyperlink. We also change the target attribute. The target attribute is by default set to "_self", which means that the link will open in the same window. By setting the target attribute to "_blank", the link will open in a new window.</p> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself