Computer >> Computer tutorials >  >> Programming >> Javascript

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


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.

<!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>