How to Create Slideshow using JavaScript?
In this blog I am wiritng about slider (webiste slideshow) . You can implement this using javascript. Implementing this unig javascript is very easy. You can do this using CSS only but that is bit difficult. In this tutorial I am creating two button next and previous and when you clcik n that image changes.
First understand that How slider works ?
Slider basically works on hiding one image and showing the next image. So we have to write a function which hides an image and show another image.
Just look after line number 79
Now after looking at function you got some idea that I am hiding one image and shoing other image.
I had created a global variable where I store current Active image and use that variable to hide the current image.
After hiding current image I update the value of that If the function is next() then I add +1 and if the function is pre() then I -1 from that variable.
After hiding and updating there is one more step that new value is valid or not.
Valid ?
Yes, Valid because suppose going next and next we reach the last image and when we click on next nothing is showing. So, for that, we need to verify that new variable(after updating) should be within the range of children of ul.
I hope you understand this tutorial
Comments
Post a Comment