JS-Dev-101 practice question 9 of 25

A developer creates a simple webpage with an input field. When a user enters text and clicks the button, the actual value must be displayed in the…

Choose your answer, then check it against the explanation.

A developer creates a simple webpage with an input field. When a user enters text and clicks the button, the actual value must be displayed in the console: HTML: JavaScript: 01 const button = document.querySelector('button'); 02 button.addEventListener('click', () => { 03 const input = document.querySelector('input'); 04 console.log(input.getAttribute('value')); 05 }); When the user clicks the button, the output is always "Hello". What needs to be done to make this code work as expected?
Answer options
Question 9 of 25

Keep practicing

Take the free JS-Dev-101 practice test

Ten exam-style questions with answers and explanations, plus the exam facts and study guides.

Start the free practice test

More questions

Other JS-Dev-101 practice questions

Scroll to Top