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 trial
Kfir Malul
1,734 PointsCouldn't understand that line: document.querySelector('.fruits').innerHTML = fruitList; Any explain? :) Tnx!
Couldn't understand that line: document.querySelector('.fruits').innerHTML = fruitList;
Any explain? :) Tnx!
1 Answer
Steven Parker
243,656 PointsThe document.querySelector method selects a single element from the page, and '.fruits' identifies elements that have the class "fruits". The method selects the first one that has this.
Then, .innerHTML is the element attribute that is associated with what the element displays on the page, and "= fruitList" assigns the content of the variable "fruitList" to that attribute.
So the total effect is to make the contents of "fruitList" appear on the page, inside the first element that has the class "fruits".
Kfir Malul
1,734 PointsKfir Malul
1,734 PointsTNX!
Steven Parker
243,656 PointsSteven Parker
243,656 PointsKfir Malul — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!