Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

jQuery selector help for all inputs apart from those within a DIV

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

Here is what I have:

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

Can anyone help please?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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" />
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading