7

正在做:

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

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

给我一个输出

0    
1   
2

为什么我的输出不是

foobar   
hello    
world

JSFiddle

4

1 回答 1

18

这样做,第一个参数是索引:

$.each(tags, function(index, tag) {  
  console.log(tag);
});
于 2013-01-10T06:39:44.580 回答