Creating an image slider part 2

Creating an Image Slider
23
2/2









Image Slider
Now we need to handle the Next and Prev button clicks and call the corresponding functions to change the image.
HTML:<div>
<button onclick="prev()"> Prev </button>
<img id="slider" src="http://www.sololearn.com/uploads/slider/1.jpg"
width="200px" height="100px"/>
<button onclick="next()"> Next </button>
</div>
JS:
The num variable holds the current image. The next and previous button clicks are handled by their corresponding functions, which change the source of the image to the next/previous image in the array.
We have created a functioning image slider!
Comments
Post a Comment