I have been working on a project and came across a codepen link https://codepen.io/robgolbeck/pen/bVGmop that is similar to what I need. However, I am trying to achieve a specific functionality where clicking on a thumbs image replaces the large image with the clicked one and removes it from the thumbs list. I want only 5 images in rotation, but currently there are 6 (5 + 1 repeated in thumbs). I've attempted to modify the JS code without success. Can anyone provide guidance on this issue? I've been stuck on it all morning. Thank you in advance.
JS
$('#thumbs img').click(function(){
$('#largeImage').attr('src', $(this).attr('src').replace('thumb','large'));
$(this).attr('src',$('#largeImage').attr('src').replace('large','thumb'));
});