我對jquery很新,希望有人能幫我解決這個小問題。我非常積極的代碼這個特殊的一塊,我想很容易讓人們有更多的經驗,所以因此這個職位。jquery與下一個和上一個按鈕幻燈片,我需要一段代碼,將幻燈片重置爲第一個圖像
我有兩個下一個和前一個按鈕一個jQuery幻燈片。當我去到現場的其他部分,然後回來,幻燈片仍然對最後顯示(我把幻燈片自動的)的圖片。在這個例子中,當我去到網站的其他部分時,幻燈片是隱藏的。
所以我想有什麼,是一段代碼,使圖像幻燈片復位到第一個圖像。
這是我已經使用了jQuery和HTML:
的Jquery:
$(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();
});
});
HTML幻燈片:
<div class="slide">
<ul>
<li><img src="img/portfolio/TM_Logos_huisstijl01.gif" />
</li>
<li><img src="img/portfolio/TM_Logos_huisstijl02.gif" />
</li>
<li><img src="img/portfolio/TM_Logos_huisstijl03.gif" />
</li>
<li><img src="img/portfolio/TM_Logos_huisstijl04.gif" />
</li>
<li><img src="img/portfolio/TM_Logos_huisstijl05.gif" />
</li>
<li><img src="img/portfolio/TM_Logos_huisstijl06.gif" />
</li>
</ul>
</div>
我希望我提供足夠的信息,並很感謝任何人誰想借峯值:)
問候, L.
編輯,這是用於項目之間滾動的代碼,這使得圖像幻燈片隱藏在另一個項目時:
$(".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;
});
小的更多信息將是有益的。你如何顯示和隱藏幻燈片? –
您好,謝謝您的諮詢:)我已添加用於製作幻燈片並隱藏的代碼。我希望這是足夠的信息? – Lalipuna8