javascript - jQuery slider doesn't rotate -


i have slider rotator on site doesn't rotate items automatically in boxes - navigation works , rotate want rotate automatically, right after enter site. js:

$(document).ready(function() {     var nbr = 0;    $('.slider').each(function() {       var slider = $(this);     //get width , height of wrapper , give ul     var wrapperwidth = $(slider).width() *  $(slider).find('ul > li').size();     $(slider).find('ul').css('width', wrapperwidth);     var wrapperheight = $(slider).height();     $(slider).find('ul').css('height', wrapperheight);      //set li width     var width = $(slider).width();     $(slider).find('ul li').css('width', width);     //set counter vars     var counter = $(slider).find('ul > li').size();     var decount = 1;     var autocount = 1;        if (counter > 1) {       //create number navigation         var createnum = 1;          $(slider).after('<ul class="numbers"><li></li></ul>');         var numbers = $(slider).parent().find('.numbers');          $(numbers).find('li:first-child').html(createnum+'_'+nbr).addclass('activenum').attr('id', 'id1_'+nbr);         while ( createnum != counter) {             createnum++;            $(numbers).append("<li id='id"+createnum+"_"+nbr+"'>"+createnum+"_"+nbr+"</li>");         }        //get number-width (number navigation should centered)         var numwidth = $(slider).find('.numbers li:first-child').width() * $(slider).find('.numbers li').size();         $(slider).find('.numbers').css('width', numwidth);       }        nbr++;    });       //make number clickable    $(".numbers li").click(function() {       var slider = $(this).closest('.sliderwrapper');       var slider0 = $(slider).find('.slider');     var clickednum = $(this).html().split('_')[0] * - $(slider0).width() + $(slider0).width();     $(slider0).find('ul').animate({ left: clickednum }, 400, 'swing', function() { });     $(slider).find('.activenum').removeclass('activenum');     $(this).addclass('activenum');     decount = $(this).html();    });       rotateswitch = function(sliderw, speed) {       var sliderwrap = sliderw;       play = setinterval(function() {          var nextnum = parseint($($(sliderwrap).find(".numbers li.activenum")).html().split('_')[0])+1;          if (nextnum > $(sliderwrap).find(".numbers li").length) {             nextnum = 1;          }          //console.log("nextnum: "+nextnum+", numbers length: "+$(sliderwrap).find(".numbers li").length);          $(sliderwrap).find(".numbers li").each(function() {             if( parseint($(this).html().split('_')[0]) == nextnum )                $(this).click();          });       }, speed);    };     makeautoslide = function(sliderwrap, speed) {       if ($(sliderwrap).length > 0 && $(sliderwrap).find(".numbers li").length > 1) {          rotateswitch(sliderwrap, speed);           $(sliderwrap).find(".slider li").hover(function() {             if ($(sliderwrap).find(".numbers li").length > 1) {                clearinterval(play); //stop rotation             }         }, function() {            if ($(sliderwrap).find(".numbers li").length > 1) {                rotateswitch(sliderwrap, speed); //resume rotation timer            }         });       }    };   }); 

i'm not sure if problem setinterval , clearinterval or wrote wrong.

i put code in jsfiddle, know how structure looks like. http://jsfiddle.net/gecbjerd/1/

i appreciate help. cheers


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -