javascript get all elements with any class code example
Example 1: javascript get all elements with class
const allElementContainGrepperClassName = document.querySelectorAll('.grepper');
// => return array of all elements
const firstElementContainGrepperClassName = document.querySelector('.grepper');
Example 2: 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.