मैं वर्तमान में भाई तत्वों के माध्यम से लूप करने की कोशिश कर रहा हूं लेकिन लूप को पहले भाई में वापस नहीं जा सकता।jQuery अगला लूप पहले बच्चे को वापस नहीं जा रहा है
मैं nextOrFirst समारोह के रूप में देखा उपयोग कर रहा हूँ here
मैं मैं क्या इस fiddle
एचटीएमएल
<div id="stories">
<div class="swapper"><p>number 1</p></div>
<div class="swapper"><p>number 2</p></div>
<div class="swapper"><p>number 3</p></div>
</div>
में प्राप्त करने के लिए जावास्क्रिप्ट
$(document).ready(function() {
$.fn.nextOrFirst = function(selector) {
var next = this.next(selector);
return (next.length) ? next : this.prevAll(selector).last();
};
setInterval(
function swap() {
$(".swapper").each(function() {
var nextItem = $(this).nextOrFirst();
$(this).html($(nextItem).html());
return;
});
}, 5000);
});
कोशिश कर रहा हूँ दोहराया गया है
कोड ठीक काम करता है, यह पहला तत्व चुनता है जब इसे अगली नहीं मिलती है, तो पूरी तरह से 'lastOrFirst', समस्या तर्क –