- 1

I didn't understand the prev() function can anyone explain this

10th Jun 2017, 3:43 PM
arul kumar
arul kumar - avatar
3 Respuestas
+ 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) }
10th Jun 2017, 6:11 PM
Maart
Maart - avatar
+ 1
I don't know much of JQuery, but I think this will help: https://www.w3schools.com/jquery/traversing_prev.asp
10th Jun 2017, 5:54 PM
Maart
Maart - avatar
- 1
I didn't understand the function prev() present in SoloLearn-javascript-under Dom events-image slider(prev())
10th Jun 2017, 5:58 PM
arul kumar
arul kumar - avatar