$('div#gallery ul.thumbs-list li a').click(function(){ $('div.product-images div.primary img').attr('src', $(this).data('image')); });