How to get the rel attribute of <a> HTML tag with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
  
<head>
</head>
  
<body>

<a id="a-id" rel="nofollow" href="http://www.collectivesolver.com/">collectivesolver</a>


<script>        

function get_a_rel() 
{
    document.getElementById("p-id").innerHTML = document.getElementById("a-id").rel;
}

/*
run:
  
nofollow
    
*/

</script>

<button onclick="get_a_rel()">Get a rel</button>

<p id="p-id"></p>

</body>
</html>

 



answered Aug 14, 2015 by avibootz

Related questions

1 answer 248 views
1 answer 221 views
1 answer 212 views
1 answer 259 views
1 answer 164 views
164 views asked Sep 20, 2019 by avibootz
1 answer 204 views
...