Jump to content
Sign in to follow this  

javascript for mutliple slides

Recommended Posts


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)

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";  



thank you for your help!


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...