我有这个Javascript功能。当我单击按钮时,该按钮消失并显示进度条。如何注册时间已启动并运行其他功能?
$('#go').click(function() {
console.log("moveProgressBar");
$('.progress-wrap').removeClass('hidden');
var getPercent = ($('.progress-wrap').data('progress-percent') / 100);
var getProgressWrapWidth = $('.progress-wrap').width();
var progressTotal = getPercent * getProgressWrapWidth;
var animationLength = 1000;
$('.progress-bar').stop().animate({
left: progressTotal
}, animationLength);
$('#go').addClass('hidden');
});
答案 0 :(得分:1)
您可以使用.animate
回调:
$('#go').click(function() {
console.log("moveProgressBar");
$('.progress-wrap').removeClass('hidden');
var getPercent = ($('.progress-wrap').data('progress-percent') / 100);
var getProgressWrapWidth = $('.progress-wrap').width();
var progressTotal = getPercent * getProgressWrapWidth;
var animationLength = 1000;
$('.progress-bar').stop().animate({
left: progressTotal
},
animationLength,
function(){
// do on animation is complete
$('#go').addClass('hidden');
});
});