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" >
Use the classList. remove() method to remove a class from a div element, e.g. box. classList. remove('my-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.
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.
$("div.Test").remove();
That'll do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With