I have the following code
function myFunction(items) {
// this prints out 11
alert(items.length);
$(items).each(function(i, item) {
// item is undefined for some reason
}
}
It I alert the length of items, it has elements in it (11 to be exact). so how could 11 items be present, but jQuery still pass undefined?
$(this)inside of your.each()callback? Nothing looks incorrect so it would be helpful to see an SSCCE.items? is it an array or an array-like object like anHTMLCollectionreturned from.getElementsByClassName()for instance. Either way why not just use a standard for loop?