簡體   English   中英

jQuery .each()不按預期迭代字符串數組

[英]jQuery .each() not iterating over array of strings as expected

這樣做:

var tags = ["foobar", "hello", "world"];

$.each(tags, function(tag) {  
  console.log(tag);
});

給我一個輸出

0    
1   
2

為什么我的輸出沒有

foobar   
hello    
world

的jsfiddle

這樣做,第一個參數是索引:

$.each(tags, function(index, tag) {  
  console.log(tag);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM