I must start with I am quite a javascript novice.
Currently I am making a website where a whole bunch of items are listed. Each item has a default image and 3 images of different angles of the product. I am using JQuery to show a full sized image over the default when the user hovers over the thumbnail.
My question, I have about 90 items. Is there an easier way to do this only in javascript, without having to nest 90 items.
It must be only HTML / CSS / Javascript
Currently for 3 items it would like this :
$(document).ready(function(){
// First thumbnail on each item
$("#thumb1-1,#thumb2-1,#thumb3-1").hover(function(){
$("#image1-1,#image2-1,#image3-1").show();$("#default1,#default2,#default3").hide();
},function(){
$("#image1-1,#image2-1,#image3-1").hide();$("#default1,#default2,#default3").show();
});
// Second thumbnail on each item
$("#thumb1-2,#thumb2-2,#thumb3-2").hover(function(){
$("#image1-2,#image2-2,#image3-2").show();$("#default1,#default2,#default3").hide();
},function(){
$("#image1-2,#image2-2,#image3-2").hide();$("#default1,#default2,#default3").show();
});
// Third thumbnail on each item
$("#thumb1-3,#thumb2-3,#thumb3-3").hover(function(){
$("#image1-3,#image2-3,#image3-3").show();$("#default1,#default2,#default3").hide();
},function(){
$("#image1-3,#image2-3,#image3-3").hide();$("#default1,#default2,#default3").show();
});
});
Rough visual
Most likely will load images at the end of the page to reduce lag, also pages will be split up to about 10 on a page
