hi how can i select empty space in the window using jquery -


hi want part of code executed when click on empty space in window there nothing no p no div nothing still see console code if click on p in window,so if there way tackle problem appreciate help.

$(document).on("click", ":not(div, p)", function(){     console.log("you clicked nothing empty zone in window" );  }); 

make sure click in body element. works if have span, a, button, etc. elements.

$('body').click(function (e) {     if (e.target == this) {         //your code here     } }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -