Change the HTML content, URL, and target of a link:
<!DOCTYPE html> <html> <body> <a id="myAnchor" href="http://www.microsoft.com">Microsoft</a> <button onclick="myFunction()">Change link</button> <script> function myFunction() {/*from w w w.j a va2 s . com*/ document.getElementById("myAnchor").innerHTML = "Examples"; document.getElementById("myAnchor").href = "https://www.java2s.com"; document.getElementById("myAnchor").target = "_blank"; } </script> </body> </html>