How do I use jQuery to select all children except

2019-01-30 14:02发布

I have a div (let's say the id is "container") with many elements in it, including a select element. I'd like to select all everything in the div except the select. Things I've tried:

$("#container *:not(select)")
$("#container *:not(#selectorid)")

//put a div around the select and...
$("#container *:not(#selectorcontainer)")
$("#container *:not(#selectorcontainer *)")
$("#container *:not(#selectorcontainer, #selectorcontainer *)")

Also tried without wildcard descendant selector, so just like all the above, but

$("#container:not(#selectorid)")

7条回答
爷、活的狠高调
2楼-- · 2019-01-30 14:36
$(#container select).siblings()

http://docs.jquery.com/Traversing/siblings

查看更多
登录 后发表回答