Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i delete all divs with a certain class name?

Tags:

Using jquery, what is the best way to delete all divs with a certain class name ? (I don't want to just hide the div but fully delete it). So if I have this code:

<div class="Test" ><div class="ABC" ><div class="Test" > 

after I call this method where class = "Test", i would just see:

<div class="ABC" > 
like image 760
leora Avatar asked Aug 13 '11 02:08

leora


People also ask

How do you remove a class from a div?

Use the classList. remove() method to remove a class from a div element, e.g. box. classList. remove('my-class') .

How do I remove all CSS from a class?

To remove all CSS classes of an element, we use removeClass() method. The removeClass() method is used to remove one or more class names from the selected element.

How can I get all of the elements with the same class name in JavaScript?

The querySelectorAll() method returns all elements within the document having the same class. To get the first element that matches the specified selector, you can use the querySelector() method.


1 Answers

$("div.Test").remove(); 

That'll do it.

like image 112
Joseph Marikle Avatar answered Oct 07 '22 17:10

Joseph Marikle