I have this piece of Javascript code:
$('#catDIV').on('click',function(){
$("#dogDIV").fadeOut(500, function() {
makeCat();
}).fadeIn(500);
});
This fades out the div “dogDIV”, runs the function “makeCat();” and fades “dogDIV” back in whenever the div “catDIV” is clicked on.
My question is, is it possible to change this code so that it will run no matter what part of the page is clicked on, and is it possible to specify certain divs that shouldn’t activate the code?
In other words, is it possible to say something like “If any part of the page is clicked, except for these particular divs, then run the code…”.
I’d like the code to run no matter where the user clicks on the page, but I don’t want it to run if the user clicks on the div “catDIV” or another div called “mouseDIV”. I’m not sure if this is possible?
I've seen this similar question: jQuery click anywhere in the page except on 1 div But is it possible to specify multiple divs that shouldn't trigger the code to run?
Any help with this would be really appreciated, thank you in advance!