Change URL and text of a hyperlink
<html> <head> <script type="text/javascript"> function myHref(){ document.getElementById('myAnchor').innerHTML="Visit Google" document.getElementById('myAnchor').href="http://www.google.com" } </script> </head> <body> <a id="myAnchor" href="http://www.java2s.com">Visit Java2s</a> <form> <input type="button" onclick="myHref()" value="Change URL and text"> </form> </body> </html>