i am new with jQuery and i want to make an array to be executed.So i make an array of same class of divs.those are like that
<div class="block"><img src="/home/ranjit/Desktop/Test/sunrise1.jpg" alt="sunset" /></div>
<div class="block"><img src="/home/ranjit/Desktop/Test/sunset-sailing.jpg" alt="sunset1" /></div>
look that each of div having different data in an array and i make the array like this
var matches = [];
jQuery(".block").each(function() {
matches.push(this);
});
now i want to run the function
function slider() {
for (var i= 0; i < len; i++){
console.log(matches[i]);
jQuery(matches[i]).show("slow");
jQuery(matches[i]).animate({left:'+=730'}, 3000, function(){
jQuery(this).animate({left:'-=730'},3000);
});
}
}
when i call the the slider function it executed the last of the div only. why i dont know, but i think it should logically executed the first div then the second div. plz help me why is this not executed like that .
$('.block')already behaves like an array, so what you're doing is completely redundant. Just assign it to a variable if you really need to.