sta*_*orn 1 jquery setinterval jquery-mobile jquery-mobile-popup
我怎样才能使用jQuery + jQuery Mobile.一段时间后弹出一个对话框消失.这是我在某种程度上写的作品.它会在一段时间后消失.但是,当我单击按钮再次激活它时它不起作用,除非我再次刷新页面.
JavaScript的
<script type="text/javascript">
$(document).on('pageinit', function(e) {
$('#postnote').click(function() {
$('#dialog').popup('open', {history: false}).delay(500).fadeOut('slow').hide();
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
这页纸
<div data-role="page" id="addnote">
<div id="dialog" data-role="popup" data-transition="fade">
<div data-role="header"><h1>Note posted</h1></div>
</div>
<div data-role="header" data-theme="a">
<h1>Add Note</h1>
</div>
<div data-role="content" data-theme="b">
<textarea id="note" rows="40" name="note"></textarea>
<a href="#" id="postnote" data-role="button" data-transition="fade" data-theme="b">Post</a>
<a href="#" data-rel="back" data-role="button" data-transition="slidefade" data-theme="a" data-direction="reverse">Back</a>
</div><!-- /content -->
</div><!-- /page -->
Run Code Online (Sandbox Code Playgroud)
你可以这样做.
$(document).on('popupafteropen', '.ui-popup', function() {
setTimeout(function () {
$(this).popup('close');
}, 5000);
});
Run Code Online (Sandbox Code Playgroud)