Yas*_* B. 9 html javascript popup jquery-mobile
我想以编程方式打开一个jQuery Mobile弹出窗口,然后在几秒后关闭它,这是我的代码:
有什么不对,因为我没有得到我想要展示的东西
$( "#p" ).popup( "open" );
setTimeout( function(){ $( "#p" ).popup( "close" ); }, 5000 );Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
<div data-role="popup" id="p" data-position-to="window" data-transition="turn"><p>This is a completely basic popup, no options set.</p></div>Run Code Online (Sandbox Code Playgroud)
eza*_*ker 14
确保您的代码在pagecreate之类的页面事件处理程序中,以便jQM初始化弹出窗口小部件:
<div data-role="page" id="page1">
<div data-role="header">
<h1>My page</h1>
</div>
<div role="main" class="ui-content">
<button id="btnpopup">Show Dynamic Popup</button>
</div>
<div data-role="popup" id="p" data-position-to="window" data-transition="turn"><p>This is a completely basic popup, no options set.</p></div>
</div>
$(document).on("pagecreate","#page1", function(){
$("#btnpopup").on("click", function(){
$("#p").popup("open");
setTimeout(function(){ $("#p").popup("close"); }, 5000);
});
});
Run Code Online (Sandbox Code Playgroud)
工作演示
| 归档时间: |
|
| 查看次数: |
27748 次 |
| 最近记录: |