How to filter undesired elements with jQuery
问题 lets take for example two divs, <div class="main right"></div> <div class="main"></div> And this jQuery snippet, as it follows: $('.main').css('background-color','red'); This will change both divs background-color to red, as normal. I'd like to know how to change that color for the divs that have only "main" as class, not "main right", 回答1: $('.main:not(.right)').css('background-color','red'); Or: $('.main').not('.right').css('background-color','red'); If had to more complicated conditions it