Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM (Retiring) Getting a Handle on the DOM Selecting by Id

logan gomez7
logan gomez7
Front End Web Development Techdegree Student 7,669 Points

Next, select the input element with the ID phraseText and assign it to the input variable.

unclear what question is asking am I adding the phraseText id to the index.html then selecting it In js/app.js? help would be nice

let button= document.getElementById('sayPhrase'); 
let input;

button.addEventListener('click', () => {
<!DOCTYPE html>
    <title>Phrase Sayer</title>
    <p><input type="text" id="phraseText"></p>
    <p><button id="sayPhrase">Say Phrase</button></p>
    <script src="js/app.js"></script>

2 Answers

Martin Jones
.a{fill-rule:evenodd;}techdegree seal-36
Martin Jones
Front End Web Development Techdegree Graduate 43,232 Points

You have answered the first part of the question correctly when you assigned the element with the 'sayPhrase' ID to the button variable.

You just need to do the exact same thing for the input variable.

let input = document.getElementById('phraseText');