jQuery.each() | div foreach jquery
Description:Agenericiteratorfunction,whichcanbeusedtoseamlesslyiterateoverbothobjectsandarrays.Arraysandarray-likeobjectswithalengthproperty(suchasafunctionsargumentsobject)areiteratedbynumericindex,from0tolength-1.Otherobjectsareiteratedviatheirnamedproperties.The$.each()functionisnotthesameas$(selector).each()[1],whichisusedtoiterate,exclusively,overajQueryobject.The$.each()functioncanbeusedtoiterateoveranycollection,whetheritisanobjectoranarray.Inthecaseofanarray,thecallbackispassedanarra...
Description: A generic iterator function, which can be used to seamlessly iterate over both objects and arrays. Arrays and array-like objects with a length property (such as a functions arguments object) are iterated by numeric index, from 0 to length-1. Other objects are iterated via their named properties.
The $.each() function is not the same as $(selector).each()[1], which is used to iterate, exclusively, over a jQuery object. The $.each() function can be used to iterate over any collection, whether it is an object or an array. In the case of an array, the callback is passed an array index and a corresponding array value each time. (The value can also be accessed through the this keyword, but Javascript will always wrap the this value as an Object even if it is a simple string or number value.) The method returns its first argument, the object that was iterated.
1
2
3
$.ea...