I made a simple slideshow using jQuery that checks how many images are in the folder using AJAX and than compares it with index of image to be shown. If the index is to be larger than the amount of images in the folder the index changes to 1 and whole slideshow starts over (and the other way round). The if statement for previous img looks like this (for the next img very alike):
if (SlideNo > SlideMin) {
SlideNo--;
} else {
SlideNo = SlideMax;
};
It works quite well. Now I am trying to implement change of image using keyup function, unfortunately I am not able to implement this if statement into the one that checks which key is pressed. I tried sth like this:
$(document).keyup(function(e){
if (e.keyCode === 27) {
$('#overlay').css('display','none');
SlideMax = -2;
$(document.body).removeClass('noscroll');
};
else if (e.keyCode === 37) {
if (SlideNo > SlideMin) {
SlideNo--;
} else {
SlideNo = SlideMax;
};
};
});
Guess it's just a syntax error but I'm not really able to find what's wrong. Thanks for your help!
Aucun commentaire:
Enregistrer un commentaire