I am a newbie to native JavaScript and am pretty much coming to grips with the operators, etc. At the moment I am currently constructing a slide.
"use strict";
var intSeconds = 3;
function loadSlider(){
flickrImgsShown = 0;
sliderImages = new Array(slides + 10);
sliderImages[0] = document.querySelector(".img");
for (var i = 1; 1 < sliderImg; i++ ) {
sliderImages[i] = document.querySelector(".img" + (i + 1));
document.querySelector(".identifer" + i);
}
function next() {
flickrImgsShown++;
if(flickrImgsShown == slides)
flickrImgsShown = 0;
transition();
clearInterval(slideTimer);
slideTimer = setInterval(timer, interSeconds * 1000);
}
function prev () {
flickrImgsShown--;
if(flickrImgsShown == -1)
flickrImgsShown = slides -1;
transition();
clearInterval(slideTimer);
slideTimer = setInterval(timer, interSeconds * 1000);
}
slideTimer = setInterval(timer, intSeconds * 1000);
function timer() {
flickrImgsShown--;
if(flickrImgsShown == -1)
flickrImgsShown = slides -1;
transition();
}
}
I am not a fan of the getelementbyid
and style.visibility
in my code. Is there a better method I can apply to call out an ID or change a style in the DOM?
querySelector()
andquerySelectorAll()
. – shmuli Mar 9 at 11:54document.getElementById()
. In fact, jQuery uses it! If you decide to use jQuery, you will be using the same method. So, cut the bloat and use it. It's a lot faster thandocument.querySelector()
. And it's more readable. – Ismael Miguel Mar 9 at 15:29