这个小玩意用于h5上的模拟加载还是可以,就是打开的时候模拟正在加载。但是实际项目中并不一定准确。因为并没有真实请求,慎用!
#p{
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
background-color: black;
opacity: .8;
color: red;
text-align: center;
}
写点脚本模拟一下
function SetProgress(value) {
$("#p").html("正在拼命加载" + value + "%");
}
var i = 0,
t;
function doProgress() {
if (i > 100) {
$("#p").fadeOut();
clearInterval(t);
return;
}
if (i <= 100) {
t = setTimeout("doProgress()", 20);
SetProgress(i);
i++;
}
}
$(document).ready(function() {
doProgress();
});
dom很简单的
<div id="p"></div>