This should'nt be that difficult but for some reason i'm having trouble with this.
I want to remove the first li from a cached ul:
var $selection = jQuery('.list').filter('.exclude');
.
<ul class="list">
<li class="exclude" >Do not Include</li>
<li>2</li>
<li>3</li>
</ul>
How do I capture the entire ul object without the first child li element in it?
Thanks
EDIT: The resulting jquery object i'm looking for is:
<ul class="list">
<li>2</li>
<li>3</li>
</ul>
Not this:
<li>2</li>
<li>3</li>
var $selection = jQuery('.list li').not('.exclude');
(You were close:) Using the .not()
(or :not
) selector and $('.list li')
elements collection (to be filtered)
$('.list li').remove('.exclude');
demo
http://api.jquery.com/not-selector/
http://api.jquery.com/not
http://jsfiddle.net/9NtLF =)
var list = $("ul.list").clone();
list.find("li.exclude").remove();
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