JQuery单击处理程序的一切,但某个对象 [英] JQuery click handler for everything but a certain object
问题描述
如何检查某个对象的所有内容?
我使用(不),但我不确定如何调用整个页面的类/标识。
$($。$。$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ b $ b}
在HTML代码中指定页面的正确方法是什么
< html>
< div class =page>
< / div>
< / body>
< / html>
我看到的是这样的:点击页面的上半部分可以工作;但是页面的底部只有背景色,点击没有注册,因为它是关闭页面 - 我怎么扩展这个,所以点击工作无处不在?
谢谢,
Michael
您可以为html元素添加点击事件。即使您是' e关闭页面:
$(html)。click(function(){...});
Demo可以在这里看到: http://jsbin.com/eguti
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
You can add a click event to the "html" element. That way you get events even if you're "off" the page:
$("html").click( function() { ... } );
Demo can be seen here: http://jsbin.com/eguti
这篇关于JQuery单击处理程序的一切,但某个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!