Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJoseph Michelini
Python Development Techdegree Graduate 18,692 PointsConfused about when it is necessary to iterate through selections and when it is not?
I'm not sure I have it straight in my head when it is necessary to use a for loop to iterate through your selections to apply styles.
Does any selection returning more than one element, even of the same kind, return a collection that needs to be iterated through?
Thanks in advance!
1 Answer
Steven Parker
231,261 PointsIt depends on what the objective is, but if you're using a selector function that returns a collection you'll probably want to iterate through them.
Note that this relates only to dynamic changes made in JavaScript. More commonly, styles will be applied to multiple items at once using CSS.
Joseph Michelini
Python Development Techdegree Graduate 18,692 PointsJoseph Michelini
Python Development Techdegree Graduate 18,692 PointsThank you Steven! That makes a lot of sense.