Hello everyone. I'm developing a post slideshow for wordpress on jquery. I got to say I'm no expert and this is my first time working with jquery or javascript. Everything works perfect the code works just fine the post rotate each x seconds, there is two div's which move post left(previous) or right(next) on click, it works fine but on the first post (0) when you click left (previous) it shows nothing since 0 - 1 = -1 there is no -1 post and what is supossed to show is the last post (4). I tried if { } else if { } but as I said I'm no expert and I can't find a solution by myself. Any help is apreciated. The code...
$("#switch-izquierda").click(
function() {
$("#lista-contenedor-rotatorio li:eq("+img_actual+")").fadeOut(1600);
img_actual = (img_actual -1) % cuenta;
$("#lista-contenedor-rotatorio li:eq("+img_actual+")").fadeIn(2000);
});
The problem is here...
img_actual = (img_actual -1) % cuenta;
When in first post (0) result is -1 what I need is to show last post(4)
If you got a solution I really appreciate it.