Answers for "javascript access collections of elements"

0

javascript access collections of elements

<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>
Posted by: Guest on November-10-2020

Code answers related to "javascript access collections of elements"

Browse Popular Code Answers by Language