Javascript DOM HTML Anchor rel Property set

Introduction

Set the value of the rel attribute to nofollow:

document.getElementById("myAnchor").rel = "nofollow";

Click the button to set the value of the rel attribute of the link to nofollow.

View in separate window

<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" href="https://www.java2s.com">Examples</a></p>

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {//w  w  w  .  j av  a2  s. com
  document.getElementById("myAnchor").rel = "nofollow";
  document.getElementById("demo").innerHTML = "The value of the rel attribute of the link changed.";
}
</script>

</body>
</html>



PreviousNext

Related