【问题标题】:How to automatically show modal with 5 seconds delay with qTip plugin?如何使用 qTip 插件自动显示 5 秒延迟的模式?
【发布时间】:2014-04-27 17:28:40
【问题描述】:

如何在 5 秒后自动弹出以下模式?我对 jQuery 或 Javascript 不太熟悉。我知道它可能与 window.onload 有关,但不太确定如何实现它。谢谢。

 <script>

    $(document).ready(function() {

        $('.tip').qtip({
        content: {
            text: $('#register'),
        },
        position: {
            my: 'center',
            at: 'center',
            target: $(document.body)
        },
        style: {
            classes: 'qtip-tipsy'
        },
        show: {
            modal: {
                on: true,
                blur: true, // Enables ability to exit when clicking on gray background
                escape: true // Enables exit by escape key
            },
            when: {

            }
        }
    })

    });

</script>

</head>
<body>

<div id="register">

    test

</div>

<button class="tip">Register</button>

【问题讨论】:

    标签: javascript jquery qtip


    【解决方案1】:

    使用setTimeout()function:

    $(document).ready(function() {
    
           setTimeout(showPopup,5000); // call showPopup after 5 seconds
    
        });
    
    
    function showPopup()
    {
    
     $('.tip').qtip({
            content: {
                text: $('#register'),
            },
            position: {
                my: 'center',
                at: 'center',
                target: $(document.body)
            },
            style: {
                classes: 'qtip-tipsy'
            },
            show: {
                modal: {
                    on: true,
                    blur: true, // Enables ability to exit when clicking on gray background
                    escape: true // Enables exit by escape key
                },
                when: {
    
                }
            }
        })
    
    }
    

    【讨论】:

    • 似乎还没有工作...应该更改 .tip 部分吗?因为现在它的目标是一个类名为“tip”的按钮。
    • put alert 是函数 showPopup 看它是否被调用?
    • 另见 firebug condole 可能会出现一些语法错误
    猜你喜欢
    • 2012-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-04
    • 1970-01-01
    相关资源
    最近更新 更多