मैं अगले() फ़ंक्शन का उपयोग करके तत्वों की एक श्रृंखला प्रदर्शित कर रहा हूं। एक बार जब मैं अंत तक पहुंच जाता हूं, तो मैं पहले तत्व पर जाना चाहता हूं। कोई विचार?jQuery: अगली() अंत तक पहुंचने पर कैसे पता लगाएं, फिर पहले आइटम पर जाएं
कोड यह रहा:।
//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);
});
मूल रूप से मैं एक "अगर" बयान है कि कहते हैं, "अगर कोई शेष 'अगले' तत्व हैं, तो पहले एक को खोजने की जरूरत है
धन्यवाद
!
thx पैट्रिक! आशाजनक लग रहा है, लेकिन मुझे "त्रुटि: $ ancestorAll ("। NewsSingle ") मिलता है। आखिरी फ़ंक्शन नहीं है" –
@ j-man86 - आप किस jQuery का उपयोग कर रहे हैं? JQuery। 1.4 में '.last()' विधि जोड़ा गया था। – user113716
@ j-man86 - बस एक संपादन करने वाला था। मैं इसके बजाए बस एक टिप्पणी छोड़ दूंगा। यदि आपको jQuery के पुराने संस्करण की आवश्यकता है, तो 'prevAll()। Last()' के बजाय, आप '.prevAll (': last')' कर सकते हैं। – user113716