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 221 views
1 answer 218 views
1 answer 213 views
1 answer 259 views
1 answer 165 views
165 views asked Sep 20, 2019 by avibootz
1 answer 205 views
...