I want to loop through all elements which are in a div
. I tried it with this code, but it only returns the main/starting div
.
What is wrong with this code?
<div id="startcontainer">
<div>anotherone</div>
<div>
one more <span>a span tag<a href="">href tag</a></span>
</div>
$('#startcontainer').each(function(index, value){ console.log(index+''+value+'-> id:'+$(this).attr("id")+'
tag:'+$(this).prop("tagName")); });
</div>