Как добавить несколько автоматических слайд-шоу на одну страницу
Проблема в том, что я получаю первый набор слайд-шоу, но не два других. Но все точки под слайд-шоу работают отлично.
Что я уже пробовал:
<html> <head> <h2>Cheapest Hotels in Goa:</h2> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> * {box-sizing: border-box;} .mySlides {display: none;} .Slides2 {display: none;} .Slides3 {display: none;} /* Slideshow container */ .slideshow-container { width: 600px; position: relative; margin: auto; } /* Slideshow container */ .slideshow-pictures { width: 600px; position: relative; margin: auto; } /* Slideshow container */ .slideshow-images { width: 600px; position: relative; margin: auto; } /* The dots/bullets/indicators */ .dot { height: 15px; width: 15px; margin: 0 2px; background-color: #bbb; border-radius: 50%; display: inline-block; transition: background-color 0.6s ease; } /* The dots/bullets/indicators */ .tod { height: 15px; width: 15px; margin: 0 2px; background-color: #bbb; border-radius: 50%; display: inline-block; transition: background-color 0.6s ease; } /* The dots/bullets/indicators */ .odt { height: 15px; width: 15px; margin: 0 2px; background-color: #bbb; border-radius: 50%; display: inline-block; transition: background-color 0.6s ease; } .active { background-color: #717171; } /* Fading animation */ .fade { -webkit-animation-name: fade; -webkit-animation-duration: 2.5s; animation-name: fade; animation-duration: 1.5s; } @-webkit-keyframes fade { from {opacity: .4} to {opacity: 1} } @keyframes fade { from {opacity: .4} to {opacity: 1} } </style> </head> <body> <div class="slideshow-container"> <div class="mySlides fade"> <img src="mdq.jpg" style="width:100%"> </div> <div class="mySlides fade"> <img src="mdq0.jpg" style="width:100%"> </div> <div class="mySlides fade"> <img src="mdq1.webp" style="width:100%"> </div> <div class="mySlides fade"> <img src="mdq2.webp" style="width:100%"> </div> <div class="mySlides fade"> <img src="mdq3.jpg" style="width:100%"> </div> <div class="mySlides fade"> <img src="mdq4.webp" style="width:100%"> </div> </div> <br> <div style="text-align:center"> <span class="dot"></span> <span class="dot"></span> <span class="dot"></span> <span class="dot"></span> <span class="dot"></span> <span class="dot"></span> </div><br><br> <div class="slideshow-container"> <div class="Slides2 fade"> <img src="pal.jpg" style="width:100%"> </div> <div class="Slides2 fade"> <img src="pal0.jpg" style="width:100%"> </div> <div class="Slides2 fade"> <img src="pal1.jpg" style="width:100%"> </div> <div class="Slides2 fade"> <img src="pal2.jpg" style="width:100%"></div> <div class="Slides2 fade"> <img src="pal3.webp" style="width:100%"> </div> <div class="Slides2 fade"> <img src="pal4.webp" style="width:100%"> </div> </div> <br> <div style="text-align:center"> <span class="tod"></span> <span class="tod"></span> <span class="tod"></span> <span class="tod"></span> <span class="tod"></span> <span class="tod"></span> </div><br> <div class="slideshow-container"> <div class="Slides3 fade"> <img src="oyo.webp"></div> <div class="Slides3 fade"> <img src="oyo0.jpg"></div> <div class="Slides3 fade"> <img src="oyo1.webp"></div> <div class="Slides3 fade"> <img src="oyo2.webp"></div> <div class="Slides3 fade"> <img src="oyo3.webp"></div> <div class="Slides3 fade"> <img src="oyo4.webp"></div><br> <div style="text-align:center"> <span class="odt"></span> <span class="odt"></span> <span class="odt"></span> <span class="odt"></span> <span class="odt"></span> <span class="odt"></span> </div> <script> var slideIndex = 0; showSlides(); function showSlides() { var i; var slides = document.getElementsByClassName("mySlides", "Slides2", "Slides3"); var dots = document.getElementsByClassName("dot", "tod", "odt"); for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } slideIndex++; if (slideIndex > slides.length) {slideIndex = 1} for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " active"; setTimeout(showSlides, 2000); // Change image every 2 seconds } </script> </body> </html>