I am trying to store image sources in an array and then add them into a list using javascript.
here is my code:
var imgSrc = new Array ("images/hangings/1.jpg","images/hangings/2.jpg");
for (var i = 0; i < prices.length; i++)
{
$('#products ul').append('<li><img src="imgSrc[0]"/></li>');
}
When i load the site it displays the image boxes where i want them to be, but the images are blank. Whats wrong?/>
edit. i tried using single quotes but i got a “missing ) after argument list” error
imgSrcneeds to be called as a function, not as a string.Also
imgSrc[0]should beimgSrc[i]so that it uses the current index your looping through (not0every time)