开发者

jquery remove specific element from a specific id

开发者 https://www.devze.com 2023-03-19 03:40 出处:网络
I have 2 div li开发者_开发知识库ke this: <div id=\"container1\"><input class=\"1\"><input class=\"2\"></div>

I have 2 div li开发者_开发知识库ke 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消