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

JavaScript

AddEventListener question

Guil created a variable with the p tag and added also the class of description. So far so good but where it lost me was when creating the add event listener step.

Why did Guil not add the class description to make it more specific. Also how did the event listener know which p tag to select if theres a lot of P tags in the HTML side.

Heres the link to the video just in case.

https://teamtreehouse.com/library/getting-and-setting-text-with-textcontent-and-innerhtml

1 Answer

Brendon Butler
Brendon Butler
4,254 Points

He did add the class "description" at around 2:42. And he used that class to identify which paragraph tag to modify.

Thanks for the fast response. I realized the whole thing and while trying to answer you back I saw and completely over saw that he did create a variable for p and the class description and it was named P. Thanks.