Jquery幻灯片使用“下一步”和“上一步”按钮,我需要一段代码将幻灯片重置为第一张图像
我是jquery的新手,希望有人能帮我解决这个小问题。我非常肯定我想要的这段代码对于有更多经验的人来说是很容易的,所以这篇文章也是如此 我有一张Jquery幻灯片,其中有一个“下一步”和一个“上一步”按钮。当我转到站点的其他部分并返回时,幻灯片仍在上次显示的图片上(我打开了自动幻灯片)。在本例中,当我转到站点的其他部分时,幻灯片是隐藏的 所以我想要的是一段代码,可以让幻灯片复位到第一张图片 这是我使用的jquery和html: Jquery:Jquery幻灯片使用“下一步”和“上一步”按钮,我需要一段代码将幻灯片重置为第一张图像,jquery,html,Jquery,Html,我是jquery的新手,希望有人能帮我解决这个小问题。我非常肯定我想要的这段代码对于有更多经验的人来说是很容易的,所以这篇文章也是如此 我有一张Jquery幻灯片,其中有一个“下一步”和一个“上一步”按钮。当我转到站点的其他部分并返回时,幻灯片仍在上次显示的图片上(我打开了自动幻灯片)。在本例中,当我转到站点的其他部分时,幻灯片是隐藏的 所以我想要的是一段代码,可以让幻灯片复位到第一张图片 这是我使用的jquery和html: Jquery: $(window).load(function()
$(window).load(function() {
var pages = $('#container #bottom .content .projects .tab .info .slide li'), current = 0;
var currentPage, nextPage;
$('#container #bottom .content .projects .tab .info .knoppen .buttons').click(function() {
currentPage = pages.eq(current);
if ($(this).hasClass('prevPic')) {
if (current <= 0)
current = pages.length - 1;
else
current = current - 1;
} else {
if (current >= pages.length - 1)
current = 0;
else
current = current + 1;
}
nextPage = pages.eq(current);
currentPage.hide();
nextPage.show();
});
});
当您在项目之间滚动时,是否总是在幻灯片分区中显示第一个li
$('.slide li').hide().filter(':eq(0)').show();
再多了解一点就会有所帮助。如何显示和隐藏幻灯片?您好,谢谢您的询问:)我添加了用于制作幻灯片显示和隐藏的代码。我希望这是足够的信息?
$(".project.buttons.panel").delegate(".button", "click", function onclick() {
var currentProject$ = $(".projects .current.project")
, project = "", nextProject$, previousProject$;
if (this.getAttribute("href").match(/#next$/)) {
nextProject$ = currentProject$.next();
// If there is no next project,
// then check the first project
if (nextProject$.length === 0) {
nextProject$ = $(".projects .project:first");
}
// If there is still no project,
// then there is something wrong
if (nextProject$.length === 0) {
throw new Error("Unable to find a project");
}
project = nextProject$.attr("id");
} else if (this.getAttribute("href").match(/#previous$/)) {
previousProject$ = currentProject$.prev();
// If there is no previous project,
// then check the last project
if (previousProject$.length === 0) {
previousProject$ = $(".projects .project:last");
}
// If there is still no project,
// then there is something wrong
if (previousProject$.length === 0) {
throw new Error("Unable to find a project");
}
project = previousProject$.attr("id");
} else {
throw new Error("Unknown command");
}
hashInfo.change({ project: project, tab: 1 });
return false;
});
$('.slide li').hide().filter(':eq(0)').show();