JAVASCRIPT-DEVELOPER-I practice question 13 of 30

Refer to HTML below: The current status of an Order: In Progress . Which JavaScript statement changes thetext ‘In Progress’ to ‘Completed’ ?

Full set: 219 questions

Domain Browser and Events

Answer options
A: document.getElementById(“status”).Value = ’Completed’ ;
B: document.getElementById(“#status”).innerHTML = ’Completed’ ;
C: document.getElementById(“status”).innerHTML = ’Completed’ ; Correct answer
D: document.getElementById(“.status”).innerHTML = ’Completed’ ;
Correct Answer:
C. document.getElementById(“status”).innerHTML = ’Completed’ ;
Explanation

The document.getElementById() method is the standard way to select a unique HTML element by its id attribute. The method requires the exact ID string ('status') as its argument. CSS selector prefixes like '#' or '.' are not used with this method. Once the element is selected, the innerHTML property is used to get or set the HTML content within that element. Assigning the string 'Completed' to the innerHTML property of the selected element correctly replaces its existing text content, 'In Progress'.

Why Incorrect

A. The .value property is used to get or set the value of form elements like or