Link hreflang Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Link

Description

The hreflang property sets or gets the language code of the linked document.

Set the hreflang property with the following Values

ValueDescription
languagecode Sets the language code of the linked document

Return Value

A String, representing the language code of the linked document

The following code shows how to return the language code of the linked document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<link id="myLink" href="http://java2s.com" hreflang="ja">
</head>/*from www .j av  a  2s.co m*/
<body>

<p>Click the button to change the language code of the linked document.</p>

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

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

<script>
function myFunction() {
    var v = document.getElementById("myLink").hreflang;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials