Javascript examples for DOM HTML Element:Anchor
The hreflang property sets or gets the value of the hreflang attribute of a link.
The hreflang attribute sets the language of a linked document.
Value | Description |
---|---|
languagecode | Sets a two-letter language code for the language of the linked document. |
A String, representing the language of the linked document
The following code shows how to Get the language code of a link:
<!DOCTYPE html> <html> <body> <p><a id="myAnchor" hreflang="en-us" href="https://www.java2s.com/">java2s.com</a></p> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w ww .j a v a2s. c o m*/ var x = document.getElementById("myAnchor").hreflang; document.getElementById("demo").innerHTML = x; } </script> </body> </html>