所以我试图完成的是你通过点击它外面的任何地方来关闭弹出窗口。但因为它是现在,如果你在哪里点击弹出里面< p>标签,它也关闭...html click,除了元素AND儿童
我现在已经得到的是:!
$('html').click(function(e) {
var popup = $('.popup');
if(popup.length) {
if(!$(e.target).is('.popup-content') || !$(e.target).is('.popup-content').find('*')) {
popup.removeClass('in');
setTimeout(function() {
popup.remove();
}, 300);
}
}
});
显然$ (e.target).is('。popup-content')。find('*')似乎不起作用。 和内容不会是一成不变的......
希望有人有一个解决方案
你能告诉你的HTML吗? – 2014-11-06 09:38:17
[How to detect a click outside an element?](http://stackoverflow.com/questions/152975/how-to-detect-a-click-outside-an-element) – 2014-11-06 09:38:25