jQuery – Remove Element

In this lesson, we will learn how to remove elements from a web page using jQuery. Let us see the jQuery methods to remove content:

  • remove()
  • empty()

jQuery remove() method

The remove() method in jQuery is used to remove the selected element and its child elements. In the below example, we will remove the <p> element:

Output

jQuery remove() Method

jQuery empty() method

The empty() method in jQuery is used to remove the child elements and content. It takes elements out of the DOM but will not remove the element. In the below example, we will remove the content of the <p> element but <p> will not get removed:

Output

jQuery empty() Method

jQuery - Add Element
jQuery - Add CSS Class
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading