Anchor hreflang Property - Javascript DOM HTML Element

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.

Property Values

languagecode Sets a two-letter language code for the language of the linked document.

Return Value

A String, representing the language of the linked document

The following code shows how to Get the language code of a link:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<p><a id="myAnchor" hreflang="en-us" href=""></a></p>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/*from w  ww .j a  v  a2s. c o  m*/
    var x = document.getElementById("myAnchor").hreflang;
    document.getElementById("demo").innerHTML = x;


Related Tutorials