Your code:
$("html").one("click", ":not(.four)", function(e){ e.stopPropagation();
sets global event delegation for the click event type. This means that whenever a click event is fired on the any element on the page, jQuery checks to see if this element matches the provided selector - ":not(.four)" - and if that happens, jQuery will call a handler on that element.
This is what happens when you click on the .four element:
The initial element in which the click event is fired is obviously the .four element. jQuery checks to see if this element matches the ":not(.four)" selector. Since this is not the case, the handler is not called on this element.
Event events trigger a bubble in the DOM tree. Since the distribution of this click event has not yet been canceled, the event fires in the next element, which is the parent of the original element - the .two element in your demo. Again, jQuery checks to see if the element matches the selector. As it does, a handler is called on this element.
As you can see, your handler will be called even if you click on the .four element. To prevent code from executing when the .four element is .four , you should explicitly check inside the handler - basically what Jason's solution does.
source share