Search code examples
javascriptjqueryjquery-selectors

Opposite of .find()


Is there an opposite of .find()?

Where $('.myclass').except('#myid');

Would grab all elements with .myclass except the element with #myid. I know I could do $('.myclass[id=myid]') in this example, but seems like it would be helpful in other cases.

Thanks

EDIT:

Thanks for the responses! Looks like I just missed seeing .not() and :not() in the documentation.


Solution

  • $('.myclass').not('#myid');
    

    http://api.jquery.com/not/