javascript 使用 JQuery 将 <div> 中的数据显示到弹出窗口中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25356797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 04:25:12 来源:igfitidea点击:
Display the data in <div> into popup using JQuery
提问by user3887236
<script type="text/javascript">
$(document).ready(function() {
$("#popup_div").dialog({
autoOpen: false
});
$("#btn_click").click(function() {
$("#popup_div").dialog("open");
//$("#popup_div").toggle("100", $("#popup_div").dialog("close"));
});
});
</script>
I wrote a function which will display the data in popup and immediately the popup will close. I need that popup stays sometime after clicking close button it will close.
我编写了一个函数,它将在弹出窗口中显示数据,并且弹出窗口将立即关闭。我需要弹出窗口在单击关闭按钮后停留一段时间,它将关闭。
回答by Rohan Kumar
回答by Miguel Mota
If you want the dialog to delay before closing then set a timeout:
如果您希望对话框在关闭之前延迟,请设置超时:
$("#popup_div").on('click', '#btnClose', function () {
setTimeout(function() {
$("#popup_div").dialog("close");
}, 1000);
});
JSFiddle example:
JSFiddle 示例: