Answers for "javascript get all elements with any class"

3

javascript get all elements with class

const allElementContainGrepperClassName = document.querySelectorAll('.grepper');
// => return array of all elements 

const firstElementContainGrepperClassName = document.querySelector('.grepper');
Posted by: Guest on January-12-2021
0

javascript get all instances of a class

MyClass.allInstances = [];
MyClass.allInstances.push(this);
//However, you need some way to figure out when to remove instances from this array, or you'll leak memory.
Posted by: Guest on May-21-2020

Code answers related to "javascript get all elements with any class"

Code answers related to "Javascript"

Browse Popular Code Answers by Language