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 questionsDomain Browser and Events
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'.
A. The .value property is used to get or set the value of form elements like or
1. Mozilla Developer Network (MDN) Web Docs, Document.getElementById(): "The Document method getElementById() returns an Element object representing the element whose id property matches the specified string. Since element IDs are required to be unique if specified, they're a convenient way to get access to a specific element quickly." (See the "Syntax" and "Parameters" sections).
2. Mozilla Developer Network (MDN) Web Docs, Element.innerHTML: "The Element property innerHTML gets or sets the HTML or XML markup contained within the element. ... you can set the innerHTML of an element to replace its existing content with new content." (See the "Value" and "Setting innerHTML" sections).
3. Salesforce Developers, Lightning Web Components Dev Guide, "Work with the DOM": While LWC promotes a specific way to interact with the DOM via this.template, it is built upon standard JavaScript. The guide's existence acknowledges that developers must understand core DOM APIs, like getElementById, which are fundamental JavaScript skills tested for this certification.
4. W3C, DOM Living Standard, Section 5.2.2, getElementById(elementId): "The getElementById(elementId) method, when invoked, must return the first element, in tree order, within the context object's tree, whose ID is elementId, and null if there is no such element." This official standard confirms the method's behavior and its string parameter.
Keep practicing
Take the free JAVASCRIPT-DEVELOPER-I practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other JAVASCRIPT-DEVELOPER-I practice questions
- Question 1A developer wants to set up a secure web server withNode.js. The developer creates a dire…
- Question 3Given two expressions var1 and var2. What are two valid ways to return the logical AND of…
- Question 4A test has a dependency on database.query. During the test the dependency is replaced wit…
- Question 5Refer to code below: function Person() { this.firstName = ’John’; } Person.prototype ={ J…
- Question 6A developer has an ErrorHandler module that contains multiple functions. What kind of exp…
- Question 8Refer to the code below: const event = new CustomEvent( //Missing Code ); obj.dispatchEve…
