HTML DOM Anchor hreflang property
Definition and Usage
hreflang property sets or returns the value of the link hreflang property.
hreflang property sets or returns the language code of the linked resource.
grammar
Setting hreflang properties:
anchorObject.hreflang="languagecode"
Back hreflang properties:
anchorObject.hreflang
值 | 描述 |
---|---|
languagecode | 被链资源的语言代码 |
Browser Support
All major browsers support hreflang property
Examples
Examples
Returns the language code of the linked resource:
<html>
<body>
<p><a id="w3s" hreflang="us-en"
href="http://www.w3cschool.cc/">W3Schools.com</a></p>
<script>
document.write(document.getElementById("w3s").hreflang);
</script>
</body>
</html>
<body>
<p><a id="w3s" hreflang="us-en"
href="http://www.w3cschool.cc/">W3Schools.com</a></p>
<script>
document.write(document.getElementById("w3s").hreflang);
</script>
</body>
</html>
Examples of the above output:
us-en
try it"
Anchor objects