单击此按钮时应显示一个弹出窗口
测试弹窗
但我在页面加载本身的这个问题上看到了这个...... 如何隐藏它,它应该只显示在弹出窗口中
$(function() {
var popup = false;
$(".open").click(function(){
alert(123);
if(popup === false){
$("#overlayEffect").fadeIn("slow");
$(this).parent().find('.popupContainer').fadeIn("slow");
$(this).parent().find('.close').fadeIn("slow");
center();
popup = true;
}
});
$(".close").click(function(){
hidePopup();
});
$(".overlayEffect").click(function(){
hidePopup();
});
function center(){
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $(".popupContainer").height();
var popupWidth = $(".popupContainer").width();
$(".popupContainer").css({
"position": "absolute",
"top": 85,
"left": windowWidth/2-popupWidth/2
});
}
function hidePopup(){
if(popup===true){
$(".overlayEffect").fadeOut("slow");
$(".popupContainer").fadeOut("slow");
$(".close").fadeOut("slow");
popup = false;
}
}
} ,jQuery);
最佳答案
看起来您在 popupContainer
div 上有一个hidden
类,但您没有为它设置任何样式。
尝试将此添加到您的样式中:
.hidden {
display: none;
}
关于jquery 在页面加载时弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12945294/