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 trialLeo Marco Corpuz
18,975 PointsCreating the list template to html at the beginning of the video.
How does the title/artist list get placed in the ordered list html element without any getElement method?
1 Answer
Steven Parker
231,269 PointsIf you're talking about line 32 (in the video, 33 in your snapshot) of "playlist.js":
list.innerHTML += this.songs[i].toHTML();
The "list" there is passed in as the argument to the function ("renderInElement"). That call is done on lines 9 and 11 (or 8 and 9) of "app.js":
var playlistElement = document.getElementById("playlist");
playlist.renderInElement(playlistElement);
So the "list" is a result of calling "getElementByID".
If that's not what you meant, please give a more specific reference to what part of the code you're asking about.
Leo Marco Corpuz
18,975 PointsLeo Marco Corpuz
18,975 Pointshttps://w.trhou.se/06g5mgq2nc
Starting at line 16 on the song.js file
Steven Parker
231,269 PointsSteven Parker
231,269 PointsLine 16 is the start of the "toHTML" function. It only builds up and returns the string, it doesn't place it in the element. Putting it in the element is done by the code parts I talked about above.