JQuery use .on() with not selector

You can actually use the :not selector with the .on method, like so.

This is a cleaner solution than filtering results per Tats_innit's answer.

$('.schemaTab').on('click', '.schema:not(.booga)', function(event) {
  // Fun happens here
});

I'm using jQuery 1.11.0.


.not() won't work because on method attaches event handlers to the currently selected set of elements in the jQuery object and uses the original selector to test whether the event should apply.

So I reckon selecting and then filtering in your case will do the trick.

API: http://api.jquery.com/on/

you could try this:

$(".schemaTab").on("click", ".schema", function (e) {

    if (!$(e.target).is(".schemaTab")) {
         // not stuff in here
    }

});

Just make sure the target matches:

$('.schemaTab').on('click', '.schema', function(e) {
    if(!$(e.target).is('.schema')) {
        return;
    }

    // Do stuff
});