【发布时间】:2013-01-20 20:53:29
【问题描述】:
我正在尝试让 jQuery Cycle 使用每张幻灯片中的唯一名称,以便能够直接链接到每张幻灯片。我在 malsups 网站上找到了这个:http://jquery.malsup.com/cycle/perma2.html
尝试将其合并到我的演示中,但无济于事,不确定我做错了什么?
演示: 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 现在用代码 sn-p 更新,整个代码在我链接到的演示中可用!
-
把
$(function() {改成$(document).ready(function() {? -
@Mooseman 他们的效果一模一样
标签: jquery hash cycle jquery-cycle