- 1
I didn't understand the prev() function can anyone explain this
3 Réponses
+ 2
I see, what they did is just defining a new function called prev():
function prev() {
var slider = document.getElementById('slider');
//In the HTML document, there's an element, with: id="slider" in the description, the code gets this element and defines a new variable slider to it
num--;
//decreasing num by 1
if(num < 0) {
num = images.length-1
//if num is under 0, it'll just take the value of the length of 'images' and decrease it by 1
}
slider.src = images[num];
//the source of the slider gets set to one of the elements in images, namely the value just before the value it had previously (because num decreased by 1)
}
+ 1
I don't know much of JQuery, but I think this will help:
https://www.w3schools.com/jquery/traversing_prev.asp
- 1
I didn't understand the function prev() present in SoloLearn-javascript-under Dom events-image slider(prev())