Home > OS >  jQuery selector for all inputs apart from those within a DIV
jQuery selector for all inputs apart from those within a DIV

Time:10-13

I've tried so many selectors but just can't get this to work

Here is what I have:

$(':input').filter(':not(#CLASSES).children()')

What can I try next?

CodePudding user response:

Have you tried to use not with a selector instead of filter?

$(":input").not("#foo :input").css("background-color","green")
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="tb1" />
<input id="tb2" />
<div id="foo">
  <input id="tb3" />
  <input id="tb4" />
</div>
<input id="tb5" />
<input id="tb6" />

  • Related