next()関数を使用して一連の要素を表示しています。でも最後になったら、最初の要素に行きたいです。何か案は?
コードは次のとおりです。
//Prev / Next Click
$('.nextSingle').click( function() {
//Get the height of the next element
var thisHeight = $(this).parent().parent().parent().next('.newsSingle').attr('rel');
//Hide the current element
$(this).parent().parent().parent()
.animate({
paddingBottom:'0px',
top:'48px',
height: '491px'
}, 300)
//Get the next element and slide it in
.next('.newsSingle')
.animate({
top:'539px',
height: thisHeight,
paddingBottom:'100px'
}, 300);
});
基本的に、「次の」要素が残っていない場合は、最初の要素を見つけるという「if」ステートメントが必要です。
ありがとう!