javascript access collections of elements
snippet in html

javascript access collections of elements

user6854

<div class="wrapper">
  <p class="box">Food</p>		<!-- Index Position 0 -->
  <p class="box">Drink</p>		<!-- Index Position 1 -->
  <p class="box">Books</p>		<!-- Index Position 2 -->
  <p class="box">Whatever</p>	<!-- Index Position 3 -->
</div>

<script>
var myCollection = document.getElementsByClassName("box");
console.log(myCollection)
myCollection[0].innerHTML = "I can change everything!"
</script>