innerHTML
Lesson 11 of 13 in Coddy's JavaScript DOM Methods course.
The property innerHTML sets or retrieves the complete HTML content (including child elements) within an element. This is useful for dynamically updating the content of a web page section.
element.innerHTML = "<b>Example Text !!</b>";Challenge
EasyYou are given HTML code that contains div with an ID content .
Using JavaScript only, change the content of this element div:
- Retrieve the div element using
getElementByIdfunction. - Set HTML content to
"<b>Updated Content</b>".
Try it yourself
<!DOCTYPE html>
<html>
<body>
<div id="content">Original Content</div>
<script src="script.js"></script>
</body>
</html>