I have made a mini image gallery which consists of one large div which has a background image of one of the galleries images. Underneath that are five thumbnail images, that when clicked, change the background image of the large div above.
All code works as expected but it looks like it could be improved. How can I rewrite it in a shorter, cleaner looking way?
$("#thumb2").on('click', function(){
$(".main-image").css('background-image', 'url(img/lrg-img/use/dscn2717.png)');
});
$("#thumb1").on('click', function(){
$(".main-image").css('background-image', 'url(img/lrg-img/use/dscn2714.png)');
});
$("#thumb3").on('click', function(){
$(".main-image").css('background-image', 'url(img/lrg-img/use/dscn2720.jpg)');
});
$("#thumb4").on('click', function(){
$(".main-image").css('background-image', 'url(img/lrg-img/use/dscn2733.jpg)');
});
$("#thumb5").on('click', function(){
$(".main-image").css('background-image', 'url(img/lrg-img/use/dscn2735.jpg)');
});