Javascript jQuery弹出/隐藏框
以下是我目前的情况: 到目前为止,我决定在打开.share框时将变量设置为false和true。打开后,我希望用户能够单击框以外的任何位置来关闭它 现在它第一次工作,但在那之后的任何时候,它都会因为某种原因搞砸Javascript jQuery弹出/隐藏框,javascript,jquery,popup,Javascript,Jquery,Popup,以下是我目前的情况: 到目前为止,我决定在打开.share框时将变量设置为false和true。打开后,我希望用户能够单击框以外的任何位置来关闭它 现在它第一次工作,但在那之后的任何时候,它都会因为某种原因搞砸 $(document).ready(function() { // user clicks on report this button $(".shareThis").click(function() { // confirma
$(document).ready(function() {
// user clicks on report this button
$(".shareThis").click(function() {
// confirmation fades in
$(".share-box").fadeIn("fast"),
// Prevent events from getting pass .share-box
$(".share-box").click(function(e){
e.stopPropagation();
});
});
$(document.body).click(function () {
$("body").click(function(){
// hide the share-box if clicked anywhere aside from the box itself
$(".share-box").fadeOut().removeClass("active");
});
});
});
添加返回值false
// user clicks on report this button
$(".shareThis").click(function() {
// confirmation fades in
$(".share-box").fadeIn(),
// Prevent events from getting pass .share-box
$(".share-box").click(function(e){
e.stopPropagation();
});
return false;
});
当$'.shareThis'单击时,它也会触发$document.body。单击在