我試圖讓jQuery Cycle使用每張幻燈片的唯一名稱來直接鏈接到每張幻燈片。我在malsups網站上發現了這個:http://jquery.malsup.com/cycle/perma2.html哈希固定鏈接的jQuery循環
試圖將它納入我的演示,但無濟於事,不知道我做錯了什麼?
DEMO:http://jsbin.com/uviram/1
即使我去http://jsbin.com/uviram/1#slide2
它仍然使我http://jsbin.com/uviram/1#slide1
..
$(function() {
var h,
hash = window.location.hash,
hashes = {},
index = 0;
$('.slideshow slide').each(function(i) {
h = $(this).data('hash');
hashes[h] = i;
});
if (hash)
index = hashes[hash.substring(1)] || index;
$('.slideshow').cycle({
fx: 'scrollHorz',
timeout: 0,
prev: $('.prev'),
next: $('.next'),
after: function(curr,next,opts) {
h = $(this).data('hash');
window.location.hash = h;
}
});
});
好了,所以,你使用的是什麼碼? –
@TomWalters現在更新代碼片段,整個代碼都可以在我鏈接到的演示中找到! – INT
更改'$(function(){'到'$(document).ready(function(){' – Mooseman