Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Lấy giá trị thuộc tính rel của liên kết với JavaScript

Thuộc tính rel của <a> chỉ định mối quan hệ với tài liệu đích (vd: nofollow, noopener, stylesheet).

Ví dụ

<!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("Giá trị rel: " + myVal);
    </script>
  </body>
</html>