1
所以我有一個頁面即時通訊嘗試添加一個快速循環通過項目列表的翻轉部分 - 但是當我有兩個獨立的列表在頁面上的列表項目一起索引爲一個大列表,而不是兩個較小的列表。Jquery - 變量被索引整個dom而不是在每個實例
本質上可變索引列表中的所有而不是在每個列表的運行
jQuery的
<script type="text/javascript">
jQuery('.flipper').each(function() {
(function flipperexec() {
var quotes = jQuery('.flipper').children(".content");
var quoteIndex = -1;
function showNextQuote() {
++quoteIndex;
quotes.eq(quoteIndex % quotes.length).fadeIn(50).delay(100).fadeOut(50, showNextQuote);
}
showNextQuote();
})();
});
</script>
一個例子的HTML表1和2
<ul class="flipper"><li class="content" style="display: none;">classes</li><li class="content" style="display: none;">coffee</li><li class="content" style="display: inline-block;">taste</li></ul>
<ul class="flipper"><li class="content" style="display: none;">classes</li><li class="content" style="display: none;">coffee</li><li class="content" style="display: inline-block;">taste</li></ul>
您:
,或者你可以從
.each()
循環傳遞的參數得到元素的引用'明星,我將不得不弄清楚發生了什麼好一點,但我使用的第一個解決方案! –