jquery 在页面加载时弹出

标签 jquery html css

http://jsfiddle.net/nVZEB/6/

单击此按钮时应显示一个弹出窗口

测试弹窗

但我在页面加载本身的这个问题上看到了这个...... 如何隐藏它,它应该只显示在弹出窗口中

$(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/

相关文章:

html - 汉堡包按钮过渡到 X 按钮,但刷新时不会作为汉堡包按钮返回

jQuery 日期选择器 : both RANGE and INLINE

javascript - 如何将内联 svg 字符串发布到我的 Controller ?

html - 如何增加 "Related Posts"和第一个相关条目之间的行距?

html - 不要在一个特定的输入上包含 css 样式

html - 阴影没有按预期工作

javascript - 如何为速度计创建 jquery 插件

jquery - 在动画滚动期间将拖动的 div 传输到其他连接的可排序对象

html - ul li 格式的 Div 问题

jquery - 如何在jquery中正确使用$(this)?