Hello. There is a script that implements the change of the image when you click on it. Everything would be fine, but the task is that when a certain number of images are clicked, the display of pictures began from the very beginning. Tell me how to implement ...

<script language="javascript"> var i=0; var image=document.getElementById("image"); var imgs=new Array('img/img1.jpg','img/img2.jpg','img/img3.jpg'); // картинки через запятую function imgsrc(){ i++; image.src=imgs[i]; } </script> 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="col-md-4 col-sm-6"> <img class="img-circle" id="image" src="img/img1.jpg" onClick="imgsrc();" > <p>Гробы <b>от 1800</b></p> </div> 

    1 answer 1

     function imgsrc(){ i++; image.src=imgs[ i % imgs.length ]; } 

    I think this option will suit you.