Whenever I need to select more than one element on a page, I can not use querySelector()
, right? Then we must use querySelectorAll()
. I've always used it as follows (img is just a hypothetical example):
img = document.querySelectorAll("img");
for (var i = 0; i < img.length; i++) {
console.log(img[i]);
}
But the other day in an argument with a friend, we have come to a standstill, and if there are too many elements on a page? Could not this cause problems for users who have slower computers? Something of the sort an infinite loop does ..
Is there another way to interact with multiple elements with the same genre without having to worry if this will not end up disrupting my user's browsing?