How do I use jQuery to select all children except a select element

后端 未结 7 883
甜味超标
甜味超标 2020-12-07 18:43

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. Thin

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 19:18

    You can also try it using traversing methods:

    $('#container').children().not('#selectorId');
    

    or being a final option:

    $('#container').children().filter(function(){
        return $(this).attr('id') !== 'selectorId';
    }
    

提交回复
热议问题