简体   繁体   English

在jQuery Mobile中添加弹出窗口

[英]Add popup in jquery mobile

I have added a list in my website like this; 我在我的网站上添加了这样的列表;

   <ul>
      <li><a href="#Video">Video</a></li>
   </ul>

Currently, when the user click this button the video page opens, however, what I want to do is, along the video page opening up, I also want to add a pop, saying "This is the video page". 当前,当用户单击此按钮时,将打开视频页面,但是,我想做的是,随着视频页面打开,我还想添加一个弹出窗口,说“这是视频页面”。

I have searched online but I can't seem to find anythiing that I need, I found this but I can't seem to intergrate my list with this code; 我已经在网上搜索过,但是似乎找不到任何需要的东西,我找到了,但是似乎无法将这段代码与我的清单整合在一起。

<a href="#popupBasic" data-rel="popup">Open Popup</a>

<div data-role="popup" id="popupBasic">
    <p>This is a completely basic popup, no options set.<p>
</div>

Also, if possible, I want the popup to close automatically after certain amount of time eg 3 seconds 另外,如果可能的话,我希望弹出窗口在一定时间(例如3秒)后自动关闭

I have tried this but only the first link opens; 我已经尝试过了,但是只有第一个链接打开了。

<div data-role="popup" id="popupBasic">
    <p>This is a completely basic popup, no options set.<p>
</div>

   <ul>
      <li><a href="#popupBasic" data-rel="popup" href="#Video">Video</a></li>
   </ul>

this uses jquery ui to accomplish what you want. 这使用jquery ui完成您想要的。 it pops up a dialog waits 3 seconds then closes it 3 seconds later 它会弹出一个对话框,等待3秒,然后在3秒后关闭

JSFiddle: jsfiddle.net/mcf2280/tbyuys9w/7/ JSFiddle:jsfiddle.net/mcf2280/tbyuys9w/7/

    $(function() {
        $("#popupBasic").dialog({ autoOpen: false });
        $(".navButton").click(function() {
            var text = $(this).text();
            $("#popupBasic").html('<p>'+text+'</p>');
            $("#popupBasic").dialog('open')
            window.setTimeout(closeAlert, 3000);
        });
        function closeAlert(){
            $("#popupBasic").dialog('close');
        } 
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM