Javascript examples for DOM:Element innerHTML
Element innerHTML Property - 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 v a 2s . c o m*/ document.getElementById("myAnchor").innerHTML = "java2s.com"; document.getElementById("myAnchor").href = "https://www.java2s.com"; document.getElementById("myAnchor").target = "_blank"; } </script> </body> </html>