我在这里尝试过,但我认为我做错了什么,可以帮忙吗?我在这里看到了一个类似的代码,刚刚进行了调整。谢谢你。
$(document).ready(function(){
$(document).scrollTop() >= 2500) {
var bar = $('.bar');
var p = $('.percents');
var interval;
var start = 0; // start animation at 0%
var end = parseInt(92); // stop progress bar on 78% just for demo
var current = start;
var countUp = function() {
// increment by one during each function call
current++;
bar.css('width', current+'%');
// update percents in html
p.html(current + "%");
// stop interval if we reached our goal (78%)
if (current === end) {
clearInterval(interval);
}
};
// change progress bar every 1000 / (78+1) milliseconds
interval = setInterval(countUp, (2500 / (end + 1)));
};
});