使用#hash/anchor而不是数字显示 jQuery 循环幻灯片
我正在开发一个单页布局网站,我使用 jQuery Cycle 在内容之间切换。
目前,我已经更改了脚本,以便它在 URL 中显示当前幻灯片(以便可以收藏当前幻灯片)。
我还可以提醒正确的 ID,但我无法让它激活幻灯片功能/效果。
$(window).bind('hashchange', function () { //detect hash change
var hash = window.location.hash.slice(1); //hash to string (= "myanchor")
alert(hash); //This Alerts the right ID/anchor of the current slide
//$('.slideshow').cycle(hash); // This doesn't work. If I use 1, 2, 3 etc. it shows the diffent slides
});
我怎样才能让它发挥作用?我错过了什么吗?
先感谢您。
I'm working on a one page layout site, where I use jQuery Cycle to switch between content.
Currently I've changed the script so it displays the current slide in the URL (to make it possible to Favorite the current slide).
I've also made it possible to Alert the right ID, but I can't get it to activate the slide-function/effect.
$(window).bind('hashchange', function () { //detect hash change
var hash = window.location.hash.slice(1); //hash to string (= "myanchor")
alert(hash); //This Alerts the right ID/anchor of the current slide
//$('.slideshow').cycle(hash); // This doesn't work. If I use 1, 2, 3 etc. it shows the diffent slides
});
How can I get this to work? Am I missing something?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有这样做,但我即将尝试这个解决方案: http:// wesbos.com/jquery-cycle-link-within-hashchange/
编辑:就像魅力一样!
I have not done it yet, but am about to try out this solution: http://wesbos.com/jquery-cycle-link-within-hashchange/
Edit: works like a charm!