There are other posts on this, but mine is set up slightly differently and I can't quite figure out th开发者_C百科e last step.
This is my Jquery for the Jcarousel slider:
function mycarousel_initCallback(carousel) {
jQuery('.jcarousel-control a').bind('click', function() {
carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr("id")));
return false;
});
jQuery('#mycarousel-next').bind('click', function() {
carousel.next();
carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
return false;
});
jQuery('#mycarousel-prev').bind('click', function() {
carousel.prev();
carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
return false;
});
jQuery('#offerings li a').bind('click', function() {
var index = $(this).attr("id").split("_");
carousel.scroll(jQuery.jcarousel.intval(index[1]));
//carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
$("#offerings li a").removeClass("active"); //Remove any "active" class
$(this).addClass("active");
return false;
});
};
This works great for adding an active class when you click on a link in the external control (#offerings), but when you use the prev and next buttons, it does not update the menu active class.
Any help appreciated :)
The problem is here
carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
The problem is you have two functions to scroll. For example:
.next()
and then you followed it by another scroll function
.scroll
Solution:
use in next()
function only next and same to previous function.
精彩评论