codeGK
Code it ALL
jQuery Remove - CodeGK
♦ jQuery Remove

♣ About jQuery Remove

To remove elements and content, there are mainly two jQuery methods:-
  • remove() :- Removes the selected element (and its child elements)
  • empty() :- Removes only the child elements from the selected element

♣ Example1: jQuery remove()

Removes the selected element (and its child elements).
Basic Syntax
$(selector).remove();
selector: the HTML element to be selected.
remove(): syntax for removing all the whole selected HTML element along with it's children.
In this example, jQuery remove() method is illustrated.
Example
Input:
Output:

♣ Example2: jQuery empty()

Removes only the child elements from the selected element.
Basic Syntax
$(selector).empty(data);
selector: the HTML element to be selected.
empty(): syntax for emptying all the child elements of selected HTML element.
In this example, jQuery empty() method is illustrated.
Example
Input:
Output:
Prev_LessonNext_Lesson
jQuery Remove