The following code alerts: “object Object”
var shipImgs = $("#div").children();
alert(shipImgs);
div contains 4 children (image tags).
<div id="div">
<img src="/imgs/spaceship_still.jpg" alt="space"/>
<img src="/imgs/spaceship_laser.jpg" alt="space"/>
<img src="/imgs/spaceship_motion.jpg" alt="space"/>
<img src="/imgs/spaceship_destroyed.jpg" alt="space"/>
</div>
I’d like each of these images to be added to an array. But before I can even do that, I need to know how to handle shipImgs… How can I access that object and get the html to push to the array?
if the div has more than one children then
$("#div").childrenwill already return you an arrayhttp://jsfiddle.net/jBVZU/
or do you want to get an array of
imgsrc??DEMO