I basically "created" the following function based on information totally from Stackoverflow:
function PreloadImageSources(arrayOfImageSources)
{
// call with PreloadImages(['src1', 'src2', etc])
var newImage = $('<img />');
$(arrayOfImageSources).each(function() {
/*
alert(this); // OK
*/
newImage.get(0).src = this; // explicit iteration because of .each
});
/*
alert(newImage.get(0).src); // still OK!
*/
// return the new array of img objects, each with their .src set
return $('<img />');
}
Both alerts show the correct string inside the function. But, once I return from the function,
var shutterImg = PreloadImageSources([options.shutterImgSrc]) [0];
alert(shutterImg.src);
this alert shows nothing as if it does not exist, in spite of the fact that I just assigned it inside the function.
What basic kernel am I missing?