How to get the value of the hreflang attribute of a link in JavaScript?

HTMLJavascriptProgramming Scripts

To get the value of the hreflang attribute of a link in JavaScript, use the hreflang property.

Example

You can try to run the following code to get the value of the href attribute of a link.

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <p><a id="anchorid" hreflang="en-us" href="https://www.qries.com/">Qries</a></p>
      <script>
         var myHrefLang = document.getElementById("anchorid").hreflang;
         document.write("Value of hreflang attribute: "+myHrefLang);
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 13:33:04
Advertisements