定义与用法
The innerHTML property sets or returns the text of the link.
innerHTML 属性可用来设置或返回连接的文字
语法
anchorObject.innerHTML=text |
举例
<html>
<head> <script type="text/javascript"> function changeLink() { document.getElementById('myLink').innerHTML="ruanchen" document.getElementById('myLink').href="http://www.ruanchen.com" document.getElementById('myLink').target="_blank" } </script>
</head> <body> <a id="myLink" href="http://www.microsoft.com">Microsoft</a> <br /><br /> <input type="button" onclick="changeLink()" value="Change link">
</body> </html> |
尝试与演示
Change text, URL, and target attribute of a link
改变连接的文字,URL和目标属性