Pre-Summer Sale Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: ac4s65

A developer creates a simple webpage with an input field.

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:

< input type= " text " value= " Hello " name= " input " >

< button type= " button " > Display < /button >

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?

A.

Replace line 02 with button.addCallback( " click " , function() {

B.

Replace line 03 with const input = document.getElementByIdName( ' input ' );

C.

Replace line 04 with console.log(input.value);

D.

Replace line 02 with button.addEventListener( " onclick " , function() {

JavaScript-Developer-I PDF/Engine
  • Printable Format
  • Value of Money
  • 100% Pass Assurance
  • Verified Answers
  • Researched by Industry Experts
  • Based on Real Exams Scenarios
  • 100% Real Questions
buy now JavaScript-Developer-I pdf
Get 65% Discount on All Products, Use Coupon: "ac4s65"