Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Dec 2019
    Posts
    1
    Member #
    61145

    Question Java Script Image Slider Explanation

    Hello,
    I've been looking for a working little & simple Java Script Image Slider for a bit longer.
    I found something now and it works pretty good. But it would help me very much, if someone could explain to me quite briefly the functionality. (I know it's probably really easy)
    Thanks in advance!
    My Code:
    Code:
    var slideIndex = 1;
    showDivs(slideIndex);
    function plusDivs(n) {
         var y = document.getElementById("slide1");
         y.style.display = "none";.
    
        showDivs(slideIndex += n);
    }
    function showDivs(n) {
      var i;
      var x = document.getElementsByClassName("mySlides");
      if (n > x.length) {slideIndex = 1}
      if (n < 1) {slideIndex = x.length}
      for (i = 0; i < x.length; i++) {
        x[i].style.display = "none";
      }
      x[slideIndex-1].style.display = "block";
    }

  2.  

  3. #2
    Junior Member
    Join Date
    Sep 2020
    Posts
    15
    Member #
    61988
    Liked
    1 times
    Overcomplicating. You are hiding next div in a line and then going back for one to show the active one.

    Try using css classes together with js. Less code with same results.

    Sent from my K7 using Tapatalk


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Tags for this Thread

All times are GMT -6. The time now is 04:15 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com