Web ベースのクイズを作成しており、タイマー バーの幅が 0 に設定されるたびに leftScroll jQuery アニメーションが起動されるようにしたいと考えています。これは、常に最初のターゲットをターゲットにしているためだと.qAnswers a
思います。毎回次を起動するにはどうすればよいですか?
リンク: http://www.carlpapworth.com/friday-quiz/#
JS:
timesUp();
function timesUp(){
$('#timerBar').animate({'width':'0px'}, 1500, function(){
nextQuestion(function(){
resetTimer();
});
});
}
function nextQuestion(event){
var $anchor = $('.qAnswers a');
$('#qWrap').stop(true, true).animate({
scrollLeft: $($anchor.attr('href')).position().left
}, 2000, function(){
nextCount();
$anchor = $anchor.next('.qContainer a');
});
}
function resetTimer(){
$('#timerBar').css('width', '99%');
timesUp();
}
「回答」をクリックしたときにアニメーションを起動するために、この JS を使用しています。
$('.qAnswers li a').bind('click',function(event){
$(this).parent().addClass('selected');
var $anchor = $(this);
$('#qWrap').stop(true, true).delay(800).animate({
scrollLeft: $($anchor.attr('href')).position().left
}, 2000, function(){
nextCount();
});
stopTimer();
event.preventDefault();
});