Jquery removes a specific item from a specific id

I have 2 divs:

<div id="container1"><input class="1"><input class="2"></div> <div id="container2"><input class="1"><input class="1"><input class="2"></div> 

Now, how to remove all class = "1", but only from container2.

+4
source share
1 answer

That should do it.

$('#container2 .1').remove();

This searches for all descendants from the element with id "container2" that belongs to the class named "1" and then removes them from the DOM.

+15
source

All Articles