Anchor hreflang Property - Change the language code of a link: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Anchor hreflang Property - Change the language code of a link:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" hreflang="en-us" href="https://www.java2s.com/">java2s.com</a></p>

<button onclick="myFunction()">change the value of the hreflang attribute of the link to "fr"</button>

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

<script>
function myFunction() {//from w  ww. java 2s  .c o m
    document.getElementById("myAnchor").hreflang = "fr";
    document.getElementById("demo").innerHTML = "The hreflang value of the link was changed from 'en-us' to 'fr'.";
}
</script>

</body>
</html>

Related Tutorials