PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are developing an HTML page that includes the following code.
<h1 id=”header”>A Static Page</hl>
You need to modify the content of the H1 element dynamically by using JavaScript.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
innerHTML
The innerHTML property sets or returns the HTML content (inner HTML) of an element.
Example
Change the HTML content of a <h1> element with id=”header”:
document.getElementById(“header”).innerHTML = “A dynamic page”;
HTML DOM innerHTML Property


Leave a Reply