JSFiddle - React, Tailwind, and code Playground
HTML
<div class="product">
<a href="http://link.to/">
<img class="mainImg" src="//lorempixel.com/60/60/city/1"/>
</a>
<div class="additionalImg">
<a class="thumb" href="#">
<img class="productImg" width="60" height="60" title="" alt="" src="//lorempixel.com/60/60/food/1/" />
</a>
<a class="thumb" href="#">
<img class="productImg" width="60" height="60" title="" alt="" src="//lorempixel.com/60/60/food/2/"/>
</a>
<a class="thumb" href="#">
<img class="productImg" width="60" height="60" title="" alt="" src="//lorempixel.com/60/60/food/3/" />
</a>
</div>
</div>
<div class="product">
<a href="http://link.to/">
<img class="mainImg" src="//lorempixel.com/60/60/city/2"/>
</a>
<div class="additionalImg">
<a class="thumb" href="#">
<img class="productImg" width="60" height="60" title="" alt="" src="//lorempixel.com/60/60/cats/1/"/>
</a>
<a class="thumb" href="#">
<img class="productImg" width="60" height="60" title="" alt="" src="//lorempixel.com/60/60/cats/2/"/>
</a>
<a class="thumb" href="#">
<img class="productImg" width="60" height="60" title="" alt="" src="//lorempixel.com/60/60/cats/3/"/>
</a>
</div>
</div>
<div class="product">
<a href="http://link.to/">
<img class="mainImg" src="//lorempixel.com/60/60/city/3"/>
</a>
<div class="additionalImg">
<a class="thumb" href="#">
<img class="productImg" width="60" height="60" title="" alt="" src="//lorempixel.com/60/60/nature/1/">
</a>
<a class="thumb" href="#">
<img class="productImg" width="60" height="60" title="" alt="" src="//lorempixel.com/60/60/nature/2/">
</a>
<a class="thumb" href="#">
<img class="productImg" width="60" height="60" title="" alt="" src="//lorempixel.com/60/60/nature/3/">
</a>
</div>
</div>
JavaScript
jQuery(document).ready(function() {
jQuery('.mainImg').each(function() {
$(this).data("original", this.src);
});
jQuery('.additionalImg a img').hover(function () {
jQuery(this).closest('.product').find('.mainImg').attr("src", this.src);
},function() {
var $main = jQuery(this).closest('.product').find('.mainImg');
$main.attr("src", $main.data("original"));
});
});