I can't figure out if this is possible, basically want to run an each function on every article and run another each function inside that each function on every li in that article, is this possible? I can post more details later.
18960 次
2 に答える
7
jQuery $.each() 関数は単なるループです。セレクターが返す項目を反復処理します。このため、ページ上のすべての UL を選択すると、その UL 項目を表示しているときに、その UL のすべての li 項目を選択し、その後同様に、各 li のすべてのスパンを選択します。アイテムがあればずっと続けられます。関係ありません。ただのループです。
$.each("ul", function(index, element)
{
var $this = $(this);
var $items = $this.find("li");
//now next loop
$.each($items, function(n, e)
{
//this is each li in this ul
});
});
于 2013-10-21T18:18:36.250 に答える
6
このような:
jQuery.each([[1,2], [3,4], [5,6]], function(index, value) {
jQuery.each(value, function(subindex, subvalue) {
console.log(subvalue);
});
});
出力:
1
2
3
4
5
6
于 2013-10-21T18:07:14.883 に答える