getElementsByTagName



examples/javascript/get_elements_by_tag_name.html
<div></div>
<div></div>
<div></div>

<script>
var fields = document.getElementsByTagName('div');
for (var i=0; i < fields.length; i++) {
  //console.log(i);
  fields[i].innerHTML = "Hello " + i;
}
</script>