Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How to iterate over the DOM

// Note: This will only work in platforms that have
// implemented NodeList.prototype[Symbol.iterator]
const articleParagraphs = document.querySelectorAll('article > p');

for (const paragraph of articleParagraphs) {
  paragraph.classList.add('read');
}
Comment

loop through dom elements javascript

//Loop thru DOM elements

var all = document.getElementsByTagName("*");

for (var i=0, max=all.length; i < max; i++) {
     // Do something with the element here
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: var notification = new Notification 
Javascript :: how to load existing json data in nuxt 
Javascript :: check if string matches a regex 
Javascript :: javascript get child element by parent id 
Javascript :: javascript copy 2d array 
Javascript :: stop page refresh on button click react 
Javascript :: javascript select change selected 
Javascript :: prettier vscode settings 
Javascript :: Google Maps JavaScript API error: InvalidKeyMapError 
Javascript :: conditional style prop react 
Javascript :: jquery document ready function 
Javascript :: how to count specific letters in string js 
Javascript :: $q.platform.is.mobile 
Javascript :: javascript keyup event enter key 
Javascript :: what is currying in javascript 
Javascript :: add on click to div using jquery 
Javascript :: get element of an array inside another array 
Javascript :: how to convert a queryset into json string 
Javascript :: javascript regex reference 
Javascript :: js key value array 
Javascript :: javascript json stringify indented 
Javascript :: tonumber javascript 
Javascript :: javascript .foreach 
Javascript :: how to get current month in express js 
Javascript :: module is not defined eslint 
Javascript :: js get day name from date 
Javascript :: how to insert an item into an array at a specific index javascript 
Javascript :: javascript loop x times 
Javascript :: call button click event in javascript 
Javascript :: javascript merge arrays of objects without duplicates 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =