• Resolved boontoony

    (@boontoony)


    Hi, I have a fixed position vertical dot menu, which is working great targeting each section of my page. I would like to create “next” and “previous” links to top and tail this menu. How do I target the immediate next or previous section depending on where I am on the page?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author malihu

    (@malihu)

    Hi,

    The way to this is via javascript. Does your theme allow you to add js scripts?
    To provide an actual working code I’d have to see your page/site.

    Thread Starter boontoony

    (@boontoony)

    Hi, thanks for your reply. Yes, my theme does use JS. Here is my basic code:

    <section id="about">content here</section>
    <section id="music">content here</section>
    <section id="video">content here</section>
    <section id="contact">content here</section>
    
    <div id="fixednav">
    	<a class="prev" rel="m_PageScroll2id" href=""></a>
    	<a class="dot about-highlight" rel="m_PageScroll2id" href="#about"></a>
    	<a class="dot music-highlight" rel="m_PageScroll2id" href="#music"></a>
    	<a class="dot video-highlight" rel="m_PageScroll2id" href="#video"></a>
    	<a class="dot contact-highlight" rel="m_PageScroll2id" href="#contact"></a>
    	<a class="next" rel="m_PageScroll2id" href=""></a>
    </div>
    Plugin Author malihu

    (@malihu)

    Can you post your page/site link? I’d have to see the exact markup in order to provide exact code.

    Thread Starter boontoony

    (@boontoony)

    Here is the link, thank you. It’s the fixed dot nav on the right.

    Plugin Author malihu

    (@malihu)

    OK add the following script in your page:

    (function($){
        $(window).on("load",function(){
            $("#scrollnav .next, #scrollnav .prev").on("click",function(e){
                e.preventDefault();
                var curr=$("#scrollnav .mPS2id-highlight"),
                    next=curr.next("._mPS2id-h"),
                    prev=curr.prev("._mPS2id-h");
                if($(this).hasClass("next")){
                    if(next.length) next.trigger("click");
                }else{
                    if(prev.length) prev.trigger("click");
                }
            });
        });
    })(jQuery);

    That should do the trick. Test it and let me know.

    Thread Starter boontoony

    (@boontoony)

    Worked a treat. Thank you so much.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Scroll to Next / Previous ID’ is closed to new replies.