I am using the following code to preload my images:
function preload(sources)
{
var images = [];
for (i = 0, length = sources.length; i < length; ++i) {
images[i] = new Image();
images[i].src = sources[i];
}
}
How can I add a class to the image object? I tried images[i].class = 'classname', but this doesn't do the trick. Any suggestions?
Thanks!
Use className
instead of class
.
images[i].className = "className";