开发者

jQuery cycle plugin help

Can someone help me do one of two things.

1) Make the cycle plugin highlight the relevant button.

  • or -

2) Make the cycle plugin stop rotating once a button is clicked.

My problem is that the images cycle, then I click a button. The cycling resumes but the previously selected button stays highlighted. Either fix will be suitable. Perhaps fix 1 is preferable but I am easy re开发者_如何学编程ally.

Here is what I have at the moment.

var $container = $('#slider .inner').cycle({ 
 fx:     'scrollHorz', 
 speed: 300,
 timeout: 4000 
}); 

$container.children().each(function(i) { 
 // There are only 3 images, this is to stop a random 4th button being created.
 if (i != 3) {
  $('<input type="button" value="'+(i+1)+'" />') 
   // append it to button container 
   .appendTo(bc) 
   // bind click handler 
   .click(function() { 
    // cycle to the corresponding slide 
    $container.cycle(i);

    $(".home_buttons input").removeClass('selected');
    $(this).addClass('selected');

    return false; 
   });
 }
});


If you use cycles pager function will build the list for you and add 'activeSlide' as a class to that item: pager just add:

pager: '#nav' 

(or whatever container you want the list built in) to your options within cycle. Demo here: x http://jquery.malsup.com/cycle/pager2.html though it sounds like you won't nessecarily need the page anchor bit

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜