我希望我的幻灯片标题(在Tumblr主题上)无限循环播放它而不必点击下一个箭头请帮忙。 代码
var interval = undefined;
$(document).ready(function() {
interval = setInterval(getNext, 3000);
$("a#next").on('click', getNext);
$("a#prev").on('click', getPrev);
});
function getNext() {
var $curr = $("#slides .slides:visible"),
$next = ($curr.next().length) ? $curr.next() : $("#slides .slides").first();
transition($curr, $next);
}
function getPrev() {
var $curr = $("#slides .slides:visible"),
$next = ($curr.prev().length) ? $curr.prev() : $("#slides .slides").last();
transition($curr, $next);
}
function transition($curr, $next) {
clearInterval(interval);
$next.css("z-index", 8).fadeIn("medium", function() {
$curr.fadeOut().css("z-index", 0);
$next.css("z-index", 7);
});
}