1. <div class="content">
    2. <div id="list">
    3. <img src="images/01.png" alt="">
    4. <img src="images/02.png" alt="">
    5. <img src="images/03.png" alt="">
    6. <img src="images/04.png" alt="">
    7. <img src="images/05.png" alt="">
    8. </div>
    9. <button id="prev"></button>
    10. <button id="next"></button>
    11. <div id="btns">
    12. <span class="current"></span>
    13. <span></span>
    14. <span></span>
    15. <span></span>
    16. <span></span>
    17. </div>
    18. </div>
    1. <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    2. <script>
    3. var index=0;
    4. $("#next").click(function(){
    5. if(!$("#list>img").is(":animated")){
    6. index++;
    7. if(index>4){
    8. index=0;
    9. }
    10. animate(index)
    11. }
    12. })
    13. $("#prev").click(function(){
    14. if(!$("#list>img").is(":animated")){
    15. index--;
    16. if(index<0){
    17. index=4;
    18. }
    19. animate(index)
    20. }
    21. })
    22. $("#btns span").click(function(){
    23. index=$(this).index();
    24. animate(index)
    25. })
    26. function animate(index){
    27. $("#list img").eq(index).fadeIn(1000).siblings().fadeOut(1000);
    28. $("#btns span").eq(index).addClass("current").siblings().removeClass("current")
    29. }
    30. </script>