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
Takuya Hirata
23,296 PointsStyling elements
I really have no idea why my code doesn't work. Check my code, please.
const toggleList = document.querySelector('#taggleList'); const listDiv = document.querySelector('.listDiv'); const input = document.querySelector('input'); const p = document.querySelector('p.description'); const button = document.querySelector('button');
toggleList.addEventListener('click', () => { listDiv.style.display = 'none'; });
button.addEventListener('click', () => { p.innerHTML = input.value + ':'; });
p.title = 'List description';
Thank you!
1 Answer
Adam N
70,280 Pointsconst toggleList = document.querySelector('#taggleList');
^ in the first variable youre not correctly selecting the id of toggleList. In the video they use getElementById for this specific part.
const listDiv = document.querySelector('.listDiv')
^ Also, there isn't a class of listDiv in index.html
Takuya Hirata
23,296 PointsThank you very much, Adam! I really appreciate it.
Takuya Hirata
23,296 PointsTakuya Hirata
23,296 PointsThe console expresses "app.js:7 Uncaught TypeError: Cannot read property 'addEventListener' of null"