<html>
<style type="text/css">
<!--
.td1 {
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: none;
border-top-color: #0000FF;
border-right-color: #0000FF;
border-bottom-color: #0000FF;
border-left-color: #0000FF;
}
.td2 {
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: solid;
border-right-style: none;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #0000FF;
border-right-color: #0000FF;
border-bottom-color: #0000FF;
border-left-color: #0000FF;
}
.tr1 {
border-top-style: solid;
border-right-style: none;
border-bottom-style: solid;
border-left-style: none;
border-top-color: #0000FF;
border-right-color: #0000FF;
border-bottom-color: #0000FF;
border-left-color: #0000FF;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
}
.value {
background-color: #0000CC;
border-top-style: solid;
border-right-style: none;
border-bottom-style: solid;
border-left-style: none;
}
-->
</style>
<div id=d></div>
<input type=text id=p>
<input type=button οnclick="progressBar(d,p.value)" value="aaa">
</html>
<script type="text/javascript">
function progressBar(div,proValue){
//限定proValue大小
if(proValue<=0){
proValue=0;
}else if(proValue>=100){
proValue=100;
}
//获取 进度条表格
var t=document.getElementById("progressBar");
//不存在则新建
if(t == null || typeof(t)=="undefined"){
t = document.createElement("table");
t.width='100';
t.border='1';
t.cellpadding='0';
t.cellspacing='0';
t.id="progressBar";
//控制 表格的行
if(t.rows.length>0){
t.deleteRow(t.rows[0]);
}
//设置 表格内样式
var nr=t.insertRow();
nr.className="tr1";
for(i=0;i<100;i++){
var nc = nr.insertCell();
nc.width=1;
nc.innerHTML=" "
}
}
//设置 进度值
for(i=0;i<proValue;i++) {
t.rows[0].cells[i].className="value";
}
for(i=proValue;i<100;i++){
if(i==0){
t.rows[0].cells[i].className="td2";
}else if(i==100){
t.rows[0].cells[i].className="td1";
}else{
t.rows[0].cells[i].className="tr1";
}
}
div.insertBefore(t);
}
</script>
js+css 实现的简易进度条效果