I could suggest instead something like
$('#mainDiv .user').not('#mainDiv #exception .user').bind('event',function() {
the not () function takes a pre-existing jquery set and removes elements from it that qualify for the selector, which is passed as a parameter.
Filtering the pool on the front panel is cleaner and more efficient (probably it doesnโt matter, but itโs good practice) than having both a selector and an if statement, and after you filter out the if statement is not needed.
as a side note, filtering for "#mainDiv # exception.user" seems strange to me. "#exception" should be the only unique identifier - unless you are worried that for some reason "#mainDiv" might be a child of "#exception".
source share