Hardly tried to close Javascript, trying to wrap my brain around function areas, but I think they wrap around me. I looked through a few posts (Niman was the most helpful), but obviously still did not understand. Attempts to start a loop over the hover method in jQuery. Need freeze functions to reach the trigger of more than one action each, but would be happy to make them work with one image exchange each at a time.
$(document).ready(function() {
imageSource = [];
imageSource[0] = 'images/img0.png'
imgArea = [];
for (var i=1; i<11; i++) {
(function( ){
imageSource[i] = 'images/img' + i + '.png';
imgArea[i] = '#areamap_Img' + i;
$(imgArea[i]).hover(
function() {
$('#imgSwap').attr('src',imageSource[i]);
},
function() {
$('#imgSwap').attr('src','images/img0.png');
});
})();
};
});
Tried the idea of using an anonymous function to determine the scope from another jQuery post. It seems to work fine, but throws undefined for the array value in the first hover function, I think, because it is an internal function (sources of hard coded image work well there).