您好我正在使用http://www.gmarwaha.com/jquery/jcarousellite/中的jquery图像滑块。这是完美的,但在回发后滑块从0开始。如何记住回发后的最后状态?这是现场演示http://sampath.ind.in
$(document).ready(function () {
$("#slidebox").jCarouselLite({
vertical: false,
hoverPause: true,
btnPrev: ".previous",
btnNext: ".next",
visible: 3,
circular: false,
start: 0,
scroll: 1,
speed: 300
});
});
答案 0 :(得分:0)
您可以使用afterEnd
回调将当前状态存储在Cookie或本地存储中,如果存在此密钥,则从那里开始。
这应该设置一个cookie(lastPosition),以后可以使用:
$(...).jCarouselLite({
...
afterEnd:function(e){$.cookie('lastPosition', e.first().index());}
...
});
要从预定位置开始,您可以执行以下操作:
$(...).jCarouselLite({
...
start: parseInt($.cookie('lastPosition'),10) || 0
...
});
要设置/检索Cookie,您可以使用此库:https://github.com/carhartl/jquery-cookie。这不是经过测试的代码,但它应该给你一个基本的想法。