querySelector vs querySelectorAll: A Common JavaScript Mistake

querySelector vs querySelectorAll – I learned this the hard way 🤦🏻 Just wasted 2 hours because my code only worked on the first button. All the others? Dead. Turns out querySelector() literally does what it says—it queries for ONE selector. I needed querySelectorAll() to grab all the buttons, then loop through them. Sometimes the answer is right there in the name and you still miss it 🤦🏻 #JavaScript #WebDevelopment #100DaysOfCode #LearningInPublic

To view or add a comment, sign in

Explore content categories