I have a list of images like that:
<div class="prizes">
<img src="img/prize1-normal.png" width="102" height="137">
</div>
<div class="prizes">
<img src="img/prize2-normal.png" width="102" height="137">
</div>
And so on.
I need to replace image when it clicks. So I wrote this script:
$('.prizes').on('click', function(){
file = $(this).find('img').attr('src');
if(file.indexOf('clicked') == -1){
var src = $(this).find('img').attr("src").replace("-normal", "-clicked");
$(this).find('img').attr("src", src);
}
});
Works fine. But now a need to toggle the previous clicked image to normal. How can I do this?