Jump to content

javascript for mutliple slides


vanina

Recommended Posts

Hi!

I need some help please  because I  don't know how to change the  javascript code for have more slides in the same page...

there's somebody that can tell me the right way to do it?...

I'm using this is code for 2 slides but I need 10 slides  ( from https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_slideshow_multiple)

<script>
var slideIndex = [1,1];
var slideId = ["mySlides1", "mySlides2"]
showSlides(1, 0);
showSlides(1, 1);

function plusSlides(n, no) {
  showSlides(slideIndex[no] += n, no);
}

function showSlides(n, no) {
  var i;
  var x = document.getElementsByClassName(slideId[no]);
  if (n > x.length) {slideIndex[no] = 1}    
  if (n < 1) {slideIndex[no] = x.length}
  for (i = 0; i < x.length; i++) {
     x.style.display = "none";  
  }
  x[slideIndex[no]-1].style.display = "block";  
}
</script>

 

 

thank you for your help!

greetings

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...