Yeah this might look crazy but I just want to know if this is possible or not. I have something like this:
$('button').click(function(){
if(variable == 10){
$('img').attr('src','img/image.jpg');
} else {
$('img').attr('src','img/image-2.jpg');
}
});
Now, the problem is I have more than 2 photos (I have 10 categories of 2 photos each) but I don't want to create 10 variables and copy that block of code 10 times. So I wondered if you can make something like changing that 'img/image...jpg' part with another javascript command or so.
var images = { 10: 'image.jpg', ..., }, defaultImg = 'image-2.jpg;