I want to do something when I click anywhere, except when I click a div and it's children. This is what I've tried so far, but it's not working (clicking on it's children still executes what is within the brackets.
$('body').on('click', '* :not(#calculator)', function(e){
I cannot use something like this:
jQuery - Select everything except a single elements and its children?
$("body > *").not("body > #elementtokeep").remove();
Because the .not
function is not something I can put inside the .on()
function.
How can I achieve this?
Use not with a comma to have both selectors: the element itself and the elements children
jQuery(document.body).on("click", ":not(#calculator, #calculator *)", function(e){
console.log(this);
e.stopPropagation();
});
Typekit requires us to include their JS file to render the fonts, e.g.: <script type="text/javascript" src="https://use.typekit.com/random-name.js"></script> <script type="text/...
Typekit requires us to include their JS file to render the fonts, e.g.: <script type="text/javascript" src="https://use.typekit.com/random-name.js"></script> <script type="text/...
This code runs fine on Firefox, but I can't make the unload event work on Chrome anymore. Did Chrome stop supporting the unload event? This is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1....
This code runs fine on Firefox, but I can't make the unload event work on Chrome anymore. Did Chrome stop supporting the unload event? This is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1....
Can you help me please to consider where to place resource (service) specific business logic in AngularJS. I feel it should be great to create some model-like abstraction over my resource, but I'm not ...
Can you help me please to consider where to place resource (service) specific business logic in AngularJS. I feel it should be great to create some model-like abstraction over my resource, but I'm not ...
I'm using sinon.js as a way to stub out dependencies in my Mocha tests. I prefer the 'spy' approach over a classic mock approach, as the introspection of the spy seems clearer and affords more ...
I'm using sinon.js as a way to stub out dependencies in my Mocha tests. I prefer the 'spy' approach over a classic mock approach, as the introspection of the spy seems clearer and affords more ...