js get all elements with class code example
Example 1: javascript get element by class
var elementsArray = document.getElementsByClassName("someclassname");
Example 2: javascript get all elements with class
const allElementContainGrepperClassName = document.querySelectorAll('.grepper');
const firstElementContainGrepperClassName = document.querySelector('.grepper');
Example 3: javascript get element by class
var elements = document.querySelector(".class");
Example 4: javascript get all classes
var allHiddenElements = document.getElementsByClassName("hidden");
Example 5: js get class property
let element = document.querySelector('.preset');
let style = getComputedStyle(element);
let bg = style.backgroundColor;
Example 6: javascript get element by class
const whiteBoxes = document.getElementsByClassName("box-white")