![]() |
In JavaScript, the appendChild() method is used to append a new child node to the end of the list of children of the specified parent node. This method is commonly used in DOM manipulation to add new elements to an existing HTML structure dynamically. Syntax:selectedElement.appendChild(newChild);
Parameters:
Return Value:The appendChild() method does not return anything instead it appends the new child element to the selected element. Example 1: The below code is a basic implementation of the appendChild() method to append a child element. HTML
Output : Example 2: The below code will explain the use of the appendChild() method to add content on click to the button. HTML
Output : |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |