本文介绍了进度条宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码旨在通过计算百分比并将其作为style.width传递来设置进度条的宽度.我是新手,因此对错误的代码表示歉意:
My code is designed to set the width of my progress bar by calculating the percentage and passing it as a style.width. I am a novice, so apologise for the bad code:
jQuery
$(document).ready(function() {
var width=(1/5*100);
$('#progress_bar').css('width','=width + "%"');
});
HTML
<div id="progress_bar" style="height:1em; background:red; display:block;"></div>
请稍等的人能帮助我,使其正常工作,并告诉我哪里出了问题,以便我可以从中学到什么?
Could someone with a second to spare please help me to get it working and show me where I've gone wrong so I can learn from this?
推荐答案
字符串'=width + "%"'
不能是css参数的值.
The string '=width + "%"'
can't be the value of a css parameter.
您可能想要
$('#progress_bar').css('width', width + "%");
这篇关于进度条宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!