I have a function that finds all the DIVS with a class of boxes. It then removes the class of visible.
I now want to make my function ignore any DIV if it has a class of important.
So basically if my DIV only has the classes of boxes and visible, visible will be removed. But if my DIV has the classes of boxes, visible and important, this DIV will be left alone and visible will not be removed.
$(this).find('.boxes').removeClass('visible');
I know this can be done in an if statement, but I was wondering if there is a better way to do this using jquery?
You can use
:not(anotherSelector)in the selector:Another way would be using
.not():