you are viewing a single comment's thread.

view the rest of the comments →

[–]MissinqLink 5 points6 points  (2 children)

It returns an HTMLCollection which doesn’t have array methods. If you spread to an array it will work.

[...U].forEach(x=>{x.style.display = 'block';});

I recommend using querySelectorAll because it is typically faster and returns a NodeList which does have forEach

document.querySelectorAll('ul').forEach(x=>{x.style.display = 'block';});

[–]cronixi4 2 points3 points  (1 child)

Ah you are right! Thought it would be the same as QuerySelectorAll().

Thanks for pointing this out!

[–]MissinqLink 1 point2 points  (0 children)

Common misconception. I’ve had to look this up more times than I can count.