When running this code, every time I click the '#right', the #slide gets incremented by 2 instead of just 1... so for example i get the 1st, 3rd and the 5th elements if there are a total 6 elements.
var present=2;
var total_slide=document.getElementById("slider").childElementCount;
$("#right").click(function()
{
for(i=1;i<=total_slide;i++) {
$("#slide"+i).css("display","none"); // hide all elements
}
$('#slide'+present).css("display","block"); // the problem : display
// only the present element
// (gets incremented by 2 )
present=(present+1)%total_slide;
});
If however i use 1,2,3 etc for eg: ('#slide'+2) in place of ('#slide'+present), get the right results, but i wanna do this dynamically ..
thanks