HTML DOM Anchor href attribute
Definition and Usage
href property sets or returns the value of the link href attribute.
href attribute specifies the URL is linked resources.
grammar
Set the href attribute:
anchorObject.href="URL"
Back href attribute:
anchorObject.href
值 | 描述 |
---|---|
URL | 被链资源的 URL |
Browser Support
All major browsers support href attribute
Examples
Examples
Return Value link href attribute:
<html>
<body>
<p><a id="w3s" href="http://www.w3cschool.cc/">W3Schools.com</a></p>
<script>
document.write(document.getElementById("w3s").href);
</script>
</body>
</html>
<body>
<p><a id="w3s" href="http://www.w3cschool.cc/">W3Schools.com</a></p>
<script>
document.write(document.getElementById("w3s").href);
</script>
</body>
</html>
Examples of the above output:
http://www.w3cschool.cc/
try it"
Anchor objects