Relevent jsFiddle: http://jsfiddle.net/julianlam/eLs9E/
For some reason, given the dataset shown in the fiddle, when I try to grab all of the elements with the data-interest-id property, among the seven li elements, I get the Number “7” as well.
The two are related, as if I add another li element, the number is “8”.
Any particular reason this is happening?
The object returned from .getElements, in addition to its results, includes a length property.
When use the Object.each() function you iterate through all the properties. For example: If you change the .each to
You’ll see that the console.log() within the each() function will show “length” as its key whereas the rest will have an index.