javascript querySelectorAll to array 1

javascript querySelectorAll to array

const spanList = [...document.querySelectorAll("span")];

Here is what the above code is Doing:
1. We’re selecting all the spans in the document.
2. We’re converting the NodeList into an array.
3. We’re iterating over the array.
4. We’re adding an event listener to each span.
5. We’re adding a class to each span.

Similar Posts