Tag: 模数

使用javascript模数通过for循环遍历文本滑块

我是jQuery和堆栈溢出的新手,所以我会尝试具体,但请耐心等待。 我正在尝试从头开始创建一个带有相关链接的文本滑块,使用模数迭代列表并重复。 这是我正在使用的代码: ul#text { position: relative; margin-bottom: 40px; height: 40px; } ul#text li { position: absolute; display: none; } .active { font-weight: bold; } Suffering is not a result of physical pain alone. It can be compounded by changes in one’s life, and changes in the self. We understand, and we can help. Aggressive […]

使用模数按字母顺序对列表进行排序

我在抓取元素列表并按字母顺序对它们进行排序时没有任何问题,但我很难理解如何使用模数进行排序。 ###更新### 这是代码工作’我的方式’,然而,我更喜欢下面提供的答案的可重用性,所以已经接受了答案。 $(document).ready( function() { $(‘.sectionList2’).each( function() { var oldList = $(‘li a’, this), columns = 4, newList = []; for( var start = 0; start < columns; start++){ for( var i = start; i < oldList.length; i += columns){ newList.push('’ + $(oldList[i]).text() + ”); } } $(this).html(newList.join(”)); }); }); 例如。 说我有以下无序列表: Boots Eyewear […]