![]() |
The innerHTML property in JavScript is used to append the dynamic HTML or text content to an element using JavaScript. It is designed to add dynamic HTML, but developers also use it to add text content as well. It can be directly used with the element by selecting it using DOM manipulation. Syntax:selctedHTMLElement.innerHTML = "contentToAppend";
Example 1: The below code shows a basic implementation of innerHTML property to append HTML directly to an element. HTML
Output: Example 2: The below code implements the innerHTML property with click event to add HTML onclick to the button. HTML
Output: |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |