Можно по классу.
<div id="main">
<div class="audio"></div>
<div class="video"></div>
<div class="audio"></div>
<div class="video"></div>
</div>
<script>
array= document.getElementById("main").getElementsByTagName("div");
num=1;
for (i= 0; i!= array.length; ++i)
{
if (array[i].className=="audio")
array[i].innerHTML= "audio " + num++;
else
array[i].innerHTML= "not audio";
};
</script>