JavaScript 参考手册
HTML DOM innerHTML 属性
改变文本, URL, 及链接目标
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <script> function changeLink() { document.getElementById('myAnchor').innerHTML = "Mifengjc"; document.getElementById('myAnchor').href = "https://www.mifengjc.com"; document.getElementById('myAnchor').target = "_blank"; } </script> </head> <body> <a id="myAnchor" href="http://www.microsoft.com">Microsoft</a> <input type="button" onclick="changeLink()" value="修改链接"> </body> </html>
运行结果:
点击运行 »