Search
 
SCRIPT & CODE EXAMPLE
 

HTML

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>
Comment

PREVIOUS NEXT
Code Example
Html :: starter bootstrap 
Html :: mimonts js 
Html :: how link back to home page html without index 
Html :: ctx arc 
Html :: h3 html 
Html :: message box html 
Html :: pattern input html 
Html :: html class 
Html :: how to add html in svg d3 
Html :: file path in html 
Html :: best background color in html 
Html :: onclick video popup in html codepen 
Html :: html number input with commas 
Html :: metro ui 
Html :: html title attribute 
Html :: how to make a button download a file in html 
Html :: navbar bootstrap 4 
Html :: show description on hover 
Html :: (i=0;i<100;i++) 
Html :: how to make a head tag in html into a child element 
Html :: angular read element from html by atribute name 
Html :: get all values in hidden field with the same name 
Html :: checkbox true odoo 13 
Html :: is there an opposit of onerror html 
Html :: nativescript scrollview full height 
Html :: show text when mouse over button html 
Html :: time sequelize html example stack overflow 
Html :: how to remove dust from laptop 
Html :: display html table only on screen larger than md 
Html :: Prozent in html 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =