使用layui弹出窗口添加进度条操作。
这个效果就是,点击一个询问层窗口,确定之后就会出现一个弹出框,弹出框会显示进度条,进度条结束后自动关闭窗口。
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <link href="../../Content/layui/css/layui.css" rel="stylesheet" /> </head> <body> <input type="button" name="load" value="加载" class="layui-btn" /> <div style="display:none;" id="show"> <div class="layui-progress layui-progress-big" lay-filter="demo" lay-showPercent="true"> <div class="layui-progress-bar" lay-percent="0%"></div> </div> </div> <script src="../../Content/layui/layui.js"></script> <script src="../../Content/jquery/jquery-1.7.2.js"></script> <script> layui.use(['layer', 'element'], function () { var layer = layui.layer, element = layui.element; $("input[name='load']").click(function () { var t = 1, fun; var confirm = layer.confirm("执行", function () { layer.close(confirm); var show = layer.open({ type: 1, content: $("#show"), success: function (layero, index) { fun = setInterval(function () { element.progress('demo', t + '%'); if (t >= 100) { clearInterval(fun); layer.close(show); } else { t++; } }, 100) }, end: function () { element.progress('demo', '0%'); clearInterval(fun); } }); }); }); </script> </body> </html>
转载:https://blog.csdn.net/tatetianos/article/details/102820198