JavaScript JavaScript and the DOM 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
Martin Jones
Front End Web Development Techdegree Graduate 41,153 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');