I have various elements with same class (cCameras). I am able to push the elements into the empty array but for some reason I cannot access the elements inside the array.
var eCamerasArray = [];
// elements in this class are being pushed into the array 'cCameras'
$(".cCameras").each (function (){ eCamerasArray.push (this); });
// Firebug gives me an array with elements inside.
console.log (eCamerasArray);
for( var i = 0; i < eCamerasArray.length; i++) {
// Firebug gives me [undefined].
console.log (eCamerasArray[i]);
}
$(".cCameras")gets you a jQuery wrapped array of DOM elements, which you can access through thegetmethod. No need to build up the array yourself.