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 trialLuca Di Pinto
8,051 PointsThere is a variable named button in app.js. Set its value to contain a reference to the button element in index.html wit
Hi everybody,
can you help me with this question? I tried in this way:
''' let button = document.getElementsById8'sayPhrase');'''
but I receive error!
What am i wrong?
Thanks
6 Answers
Tijo Thomas
9,737 PointsYou have the right idea, but you just added an extra letter. The code should be:
let button = document.getElementById("sayPhrase");
You need to remove the "s" from "getElementsById" since that's not an actual method.
FHATUWANI Dondry MUVHANGO
17,796 Pointsbutton = document.getElementById("sayPhrase");
that is the correct way of putting it........because if you try what Thomas said, it will give a an error because of the variable 'button' will be duplicated
Ben Schnell
14,763 PointsI had this question too but my problem was I forgot to include the "", or '' around the id name.
let button = document.getElementById("sayPhrase");
Danielle Verduzco
3,328 PointsThis is the correct answer:
button = document.getElementById("sayPhrase");
Starky Paulino
Front End Web Development Techdegree Student 6,398 Pointslet button = document.getElementById('sayPhrase'); let input = document.getElementById('phraseText');
button.addEventListener('click', () => { alert(input.value); });
Khalid Yousif
2,785 Pointslet button; let input; button = document.getElementById("sayPhrase"); button.addEventListener('click', () => { alert(input.value); });