0
我使用的是引导进度条,它被设置为零使用jQuery初始化
<div class="progress-bar progress-bar-success" id="p1"
role="progressbar" aria-valuenow="0"
aria-valuemin="0" aria-valuemax="100" style="width:0%">
我用下面的jQuery代码初始化进度条
$.ajax({
type: "POST",
dataType: "json",
url: "myurl.php",
data: data
}).done(function(msg) {
console.log(msg);
var pid = msg.pid;
var colour = msg.colour;
var comp = msg.comp;
console.log('pid = ' + pid);
console.log('colour = ' + colour);
document.getElementById(pid).style.width = comp;
document.getElementById(pid).innerHTML = comp + '% Complete';
document.getElementById(pid).classList.add(colour);
});
我的引导进度条我从ajax请求获得有效数据,
Object {pid: "p1", comp: 7, colour: "progress-bar-success"}
但是,进度栏不更新。如果我初始化HTML中的栏以1%开始,它可以使用上面的代码。有没有办法让这个使用jQuery进行初始化?
你错过了''%,同时增加宽度是多少?还是它是一个错字? –