gpt4 book ai didi

javascript - 一段时间后关闭Bootstrap Modal

转载 作者:行者123 更新时间:2023-12-01 01:46:50 25 4
gpt4 key购买 nike

我有一个绕圈旋转的 gif 图像。我把它放在引导模式中。这是我的进度条。我希望该模式显示大约 5 秒,然后它会自行关闭。这是我的代码:

<?php
function progressBar($total){
sleep($total);

return "modal";
}
?>

<!-- Modal ProgressBar -->
<div class="modal fade" id="progressBarCenter" tabindex="-1" role="dialog" aria-labelledby="progressBarCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="progressBarLongTitle">Your Script Is Executing...</h5>
<button type="button" class="close" data-dismiss=<?php progressBar(5); ?> aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<img src="webapps/images/progressBar.gif">
</div>
</div>
</div>
</div>

这有点工作。例如,它会休眠 5 秒,然后加载整个页面。根本不是我想要的。用户可以单击按钮来启动模式,没有问题。一旦激活,它需要休眠 5 秒,然后自行关闭。如图所示,它关闭当前或事件模式。

我该如何去做呢?

最佳答案

您可以使用以下脚本在 5000 毫秒后关闭 Bootstrap Modal:

<script>
$(document).ready(function () {
$("#buttonID").click(function(){
setTimeout(function() {
$('#progressBarCenter').modal('toggle');
}, 5000);
});
});
</script>

关于javascript - 一段时间后关闭Bootstrap Modal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51884402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com