我不想要进度条,我只想将数字设置为某个百分比
$('#animate_percent').click(function() {
//How the h#$%^ is this *%&&^*
});
<!--Animate 20% to 50%-->
<span class="tabs_percent">20%</span>
答案 0 :(得分:2)
您可以使用setInterval()
:
var counter;
$('#animate_percent').on('click', function(e) {
e.preventDefault();
var $percent = $('.tabs_percent'),
curr = parseInt($percent.text()),
to = 50;
counter = window.setInterval(function() {
if(curr <= to)
{
$percent.text((curr++)+'%');
}
else
{
window.clearInterval(counter);
}
}, 20);
});