Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery remove specific element from a specific id

Tags:

jquery

I have 2 div like this:

<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 do I remove all class="1" but only from the container2.

like image 370
Yannick Avatar asked Dec 05 '22 21:12

Yannick


1 Answers

This should do it.

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

This seeks all descendants from the element with id "container2" which belongs to the class named "1" and then remove them from the DOM.

like image 160
Jamie Treworgy Avatar answered Dec 07 '22 10:12

Jamie Treworgy