Need help changing the images with mouseover and mouse out with preloaded images. I was able to figure out the preloading but I can't get the image to change. If anybody can help me out it would be greatly appreciated.
"use strict";
var $ = function(id) { return document.getElementById(id); };
window.onload = function preload() {
var image1 = $("image1");
var image2 = $("image2");
// preload images
var links = $("image_list").getElementsByTagName("a");
var i, link, image;
for(i = 0; i < links.length;i++){
link = links[i];
image = new Image();
image.src = link.href;
}
// attach mouseover and mouseout events for each image
image1.mouseover=function(){
image1=image.src="images/release.jpg";
};
image1.onmouseout = function() {
image1=image.src="images/hero.jpg";
};
image2.onmouseover = function() {
image.src="images/deer.jpg";
};
image2.onmouseout= function(){
image.src="images/bison.jpg";
};
};