繁体   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