Interactive online courses HTML Academy
2026-03-09 14:12 Diff

We found all products on the page. Now we need access each found DOM element from the collection one by one and add the appropriate classes to it. How do we do it?

Note that the DOM collection obtained with querySelectorAll is similar to an array. It’s really so, it is similar to it, but it is not an array. Therefore such collections are also called pseudo-arrays. We’ll talk in detail about the differences between collections and arrays in other courses, but for now, we’ll go over our DOM collection. This can be done using the for we are already familiar with.

We’ll go through the found products and temporarily add to each DOM element the availability class product--available. That way we’ll make sure that the loop really works.