开发者

Show jQuery cycle slide by using #hash/anchor, not numbers

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?

Tha开发者_C百科nk you in advance.


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜