设置进度条宽度 <div id="p" style="height:10px;background:red;width:0px;"></div>
<script>var p=document.getElementById('p');var i=0;var a=setInterval(function(){i+=1;p.style.width=i+"px";if(i==100)clearInterval(a)},20);</script>
<script>var p=document.getElementById('p');var i=0;var a=setInterval(function(){i+=1;p.style.width=i+"px";if(i==100)clearInterval(a)},20);</script>
解决方案 »
- JavaScript函数里面能用el表达式么?
- 关于用JS实现三联动,高手快进来啊 ,急!
- 【原创】SlideView 图片滑动(扩展/收缩)展示效果
- js alert 对象 与遍历 的 问题 求解答
- 求jquery如何根据某个属性的长度过滤数据??
- 在页面上设置页面的属性!急急急!
- 谁能帮我实现这样的效果,可能比较简单!!!!!!!!
- 哪位有禁止页面打开源代码、拷贝和打印的代码!!
- 求助:TEMPLATEPRINTER 出现没有权限的错误。
- 使用this.__proto__[key]=obj[key];为什么浏览器会多多处一段输出内容
- flash动作代码解读
- 输出"object HTMLSelectElement" 怎么才能把数据的DOM列出来?
0.9*t的t是什么?
t是当前的时间呀。下面的代码是一个简单的例子, $ibar 表示内部蓝色的进度条 now*100/900 是当前的进度。一会儿给你写一个完整的例子
$ibar.animate(
{
"width":"900px"
},
{
duration: 3000,
step:function(now, fx){
console.log(now*100/900);
}
}
);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>进度条</title>
<style type="text/css">
.progress{width: 900px; height: 16px; background-color: #CCC; position: relative;}
.progress .ibar {width: 0px; height: 16px; background-color: #9370DB; position: absolute;}
.progress .num{position: absolute;}
</style>
</head>
<body>
<div class="content">
<div class="progress">
<div class="ibar" id="ibar"></div>
<div class="num" id="num">0</div>
</div>
</div>
</body>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(function(){
$("#ibar").animate(
{"width":"900px"},
{
duration:3000,
easing:"linear",
step: function(now, fx){
$("#num").css({"left":now+"px"}).html(parseInt(now/9));
}
}
)
})
</script>
</html>