Follow up to my previous question - I want to use a button to show / hide multiple elements with the same class name using JS, yet it appears that I can only change the firs
var X = document.querySelectorAll(".className");
for (var i = 0; i < X.length; i++) {
X[i].style.cssProperty = someNumber + "unitType";
}
Example: X[i].style.width = 100 + "%";
If you want it to apply random integers:
var X = document.querySelectorAll(".className");
for (var i = 0; i < X.length; i++) {
var rand = Math.floor(Math.random() * someNumber);
X[i].style.cssProperty = rand + "unitType";
}