JQuery: How to check if element has only this class, and no other class?

class, javascript, jquery, select

Solution

$(".wrapper").children("[class=qe]")

Change the selector to match elements where the `class` equals `"qe"`.

Problem

I'm trying to come up with a way to select Element 2. ``` <div class="wrapper"> <div class="qe datepicker">Element 1</div> <div class="qe">Element 2</div> <div class="qe fileuploader">Element 3</div> <div class="qe fileuploader datepicker">Element 4</div> </div> ``` Though I haven't tested this code, I can do something like this, but it's kinda stupid and I want a more generic way: ``` var wanted_elements = $('.wrapper').children('.qe').not('.datepicker').not('.fileuploader'); ``` Any thoughts on this? Thanks in advance!

Original source