定义与用法
The href property sets or returns the URL of the linked resource.
href 属性可用来设置或返回连接的URL资源
语法
举例
<html>
<head> <script type="text/javascript"> function changeLink() { document.getElementById('myLink').innerHTML="ruanchen" document.getElementById('myLink').href="http://www.ruanchen.com" document.getElementById('myAnchor').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和目标属性