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

1 Answer

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

<a id="a-id" type="text/html" href="http://www.collectivesolver.com/">collectivesolver</a>


<script>        

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

/*
run:
  
text/html
    
*/

</script>


<button onclick="get_a_type()">Get a type</button>

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

</body>
</html>

 



answered Aug 14, 2015 by avibootz

Related questions

1 answer 305 views
1 answer 311 views
1 answer 309 views
1 answer 351 views
1 answer 261 views
261 views asked Sep 20, 2019 by avibootz
1 answer 288 views
...