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

HTMLJavascriptProgramming Scripts

To get the value of the rel attribute of a link in JavaScript, use the rel property. The rel is used to set the following status of a page i.e. follow and nofollow.

Example

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

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <p><a id="anchorid" rel="nofollow" href="https://www.qries.com/">Qries</a></p>
      <script>
         var myVal = document.getElementById("anchorid").rel;
         document.write("Value of rel attribute: "+myVal);
      </script>
   </body>
</html>
raja
Published on 26-Feb-2018 14:21:35
Advertisements