Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery click handler for everything but a certain object

Tags:

html

jquery

How do I check for a click on everything but a certain object?
I use (not), but I'm not sure how to call the class / id of the entire page.

$(".page").not("#divInfoBox").click(function (event) {

}

What's the correct way in the HTML code to specify page, as I have something like:

<html>
<body>
    <div class="page">  
    </div>
</body>
</html>

What I see is this: Clicking on the top half of the page works; but the bottom of the page, where there is nothing but background color, the click does not register because it is "off the page" -- how do I extend this so the click works everywhere?

Thanks, Michael

like image 873
Dirk Avatar asked Nov 22 '25 08:11

Dirk


1 Answers

Try this:

$("body:not('#divInfoBox')").click(function (event) {

});

Read the doc page for the not selector:

http://docs.jquery.com/Selectors/not

like image 54
karim79 Avatar answered Nov 24 '25 00:11

karim79



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!