wordpress - Keep track of button hits for an rss feed carousel with jquery -
i'm making carousel puts posts various rss feeds number of divs (slides). 1 slide shows @ time, , have left , right button uses animate() move slides in appropriate direction. i'm showing 10 slides (numbered 0 9). i'd stop left button working when slide 9 displayed, , stop right button working when slide 0 displayed in order avoid whitespace showing. works far, can't find way keep track of slide i'm on in jquery script. here's have far: script included in section on wordpress site. id #1 refers carousel #1; #left , #right refer buttons.
$(document).ready(function(){ $("#1").data("slide_num",0); $("#1 #left").click(function(){ if($("#1").data("slide_num") < 9){ $("#1 .item").animate({left: "-=800px"}, 250); $("#1").html(function(){ var $this = $(this); var $slide_num = $this.data("slide_num") + 1; $this.data("slide_num",$slide_num); }); }); }); $("#1 #right").click(function(){ if($("#1").data("slide_num") > 0){ $("#1 .item").animate({left: "+=800px"}, 250); $("#1").html(function(){ var $this = $(this); var $slide_num = $this.data("slide_num") - 1; $this.data("slide_num",$slide_num); }); }); }); });
what doing wrong? need store , keep track of variable on server-side? tried using variable named slide_num instead of .data() method, didn't work either. i'd appreciate on one.
Comments
Post a Comment