jQuery - Multiple Selectors in a :not()?

后端 未结 3 947
攒了一身酷
攒了一身酷 2021-02-03 17:58

I cant seem to get the following working:

$(\'input:not([type=radio][type=checkbox])\').live(\'click\', function() {
    alert(\"You haven\'t clicked a radio or          


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-03 18:10

    The syntax inside the not() is identical to the normal selector syntax, so if you want to match things that are not either of those things, you use a selector in the not that would match both (since essentially you're negating the selector). How do you do that? The same way you apply styles to multiple selectors at once in CSS, with a comma, as so:

    $('input:not([type=radio],[type=checkbox])')
    

    That should select all inputs the not [type=radio] and not [type=checkbox]

提交回复
热议问题