进度条宽度
我的代码旨在通过计算百分比并将其作为style.width传递来设置进度条的宽度。 我是新手,所以为坏代码道歉:
JQuery的
$(document).ready(function() { var width=(1/5*100); $('#progress_bar').css('width','=width + "%"'); });
HTML
有没有第二个空闲的人请帮助我让它工作,并告诉我我哪里出错了所以我可以从中学到什么?
http://jsfiddle.net/SyxAM/
字符串'=width + "%"'
不能是css参数的值。
你可能想要
$('#progress_bar').css('width', width + "%");
这将解决您的问题
var width=(1/5*100); $('#progress_bar').css('width',width + "%");
你的变量附加是错误的。它应该是这样的;
$(document).ready(function() { var width=(1/5*100); $('#progress_bar').css('width', width + "%"); });
你可以在这里看到http://jsfiddle.net/SyxAM/2/