Doing:
var tags = ["foobar", "hello", "world"];
$.each(tags, function(tag) {
console.log(tag);
});
Gives me an output of
0
1
2
Why is my output not
foobar
hello
world
JSFiddle
Doing:
var tags = ["foobar", "hello", "world"];
$.each(tags, function(tag) {
console.log(tag);
});
Gives me an output of
0
1
2
Why is my output not
foobar
hello
world
JSFiddle
Share Improve this question asked Jan 10, 2013 at 6:38 AyushAyush 42.5k51 gold badges167 silver badges241 bronze badges 1- here you go api.jquery.com/jQuery.each – NullPoiиteя Commented Jan 10, 2013 at 6:51
1 Answer
Reset to default 19Do this, the first parameter is for index:
$.each(tags, function(index, tag) {
console.log(tag);
});