我想从两个 jquery 变量的除法中获取值,并用它来更改 div 的宽度。
我认为问题出在 animate({width:'"+percent+"%'});
这里是 jquery:
var x = 56;
var y = 64
var percent = Math.ceil((x/y)*100);
$(".box").animate({width:'"+percent+"%'});
这是 html:
<div class="box"></div>
最佳答案
你的字符串连接有问题,就这样
$(".box").animate({
width: percent + '%'
});
关于javascript - 使用 jquery 变量按宽度为 div 设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20989463/