JQuery empty()
The empty()
method in JQuery is used to remove all child nodes from the selected element(s). It does not remove the selected element(s) itself, only their children.
Syntax
$(selector).empty();
The $(selector)
specifies the element(s) to be emptied.
Use
The empty()
method is often used to reset or clear the content of an HTML element. It is commonly used in web applications that involve dynamic content or user input.
Example
Here is an example of using the empty()
method in JQuery: