我正在尝试使用此图像滑块从文件夹位置获取图像,而不是使用 .eq() 来获取图像,但我无法弄清楚如何去做。
var pages = $('#container li'),
current = 0;
var currentPage, nextPage;
var get_images = new Array("1.jpg", "2.jpg");
var handler = function () {
$('#container .button').unbind('click');
currentPage = pages.eq(current);
if ($(this).hasClass('prevButton')) {
if (current <= 0) current = pages.length - 1;
else current = current - 1;
nextPage = pages.eq(current);
nextPage.css("marginLeft", -604);
nextPage.show();
nextPage.animate({
marginLeft: 0
}, 800, function () {
currentPage.hide();
});
currentPage.animate({
marginLeft: 604
}, 800, function () {
$('#container .button').bind('click', handler);
});
} else {
if (current >= pages.length - 1) current = 0;
else current = current + 1;
nextPage = pages.eq(current);
nextPage.css("marginLeft", 604);
nextPage.show();
nextPage.animate({
marginLeft: 0
}, 800, function () {});
currentPage.animate({
marginLeft: -604
}, 800, function () {
currentPage.hide();
$('#container .button').bind('click', handler);
});
}
}
$('#container .button').click(handler);