JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<img class="data-img" src="http://alcovegan.myjino.ru/toster-454154/some.jpg" width="250px" alt="">

<img class="data-img" src="http://alcovegan.myjino.ru/toster-454154/some1.jpg" width="250px" alt="">

<img class="data-img" src="http://alcovegan.myjino.ru/toster-454154/some2.jpg" width="250px" alt="">

JavaScript

function togglePic(el) {
	var src = $(el).attr("src");
     if (src.indexOf(".jpg") > -1) {
         src = src.replace('.jpg','.gif' );
     } else {
         src = src.replace('.gif','.jpg' );
     }
     $(el).attr('src', src);
}

$('.data-img').on('click', function() {
	togglePic(this)
})