Prev & Next page BTNs traveling through the menu

Prev & Next page BTNs traveling through the menu

I'd like to add 2 buttons down on my pages that go to the previous and next pages and, if possible, take their links straight out of the navigation already present (and relative to the page I'm on). I've only gotten so far with this for days and I could sure use some handouts :p

The menu is the Foundation off-canvas one and it poses problems for me because of all the nesting and stuff.

I would prefer if I could get the actual links straight out of the ul.off-canvas-list, but I can't find how to skip over the unuseful '#' links and <labels>.

This is what I think worked in part for the Next BTN, but it doesn't know how to skip the unuseful <li>'s so gets stuck at the end of a submenu. And I just notice it only seems to search for the current page in any of the .left-submenus as well. There are pages without submenus too.

  1. $("#next-page-BTN").on("click", function(e) {
  2.       e.preventDefault();      // prevent # being added to page in url
  3.       var page = location.pathname.substring(1);
  4.       if (!page) {page = index.php}  // in case of domain name only
  5.       // locate current <li> position in submenu
  6.       var currentLink = $('.left-submenu a[href$="'+ page + '"]').parent('li');
  7.       var nextLink = $(currentLink).next().find('a').attr('href');
  8.       window.location = nxtLink;
  9. });

I guess another method may be to clone the ul.off-canvas-list and then use .remove() for some of the unuseful links? But again the nesting is killing me there...
Doing it this way may at least give a clean list that is easy to prev / next in.
If you choose to help me with the first tactic, I may need the handouts for the Prev *and* Next code, as possibly they may differ more than replacing 'next()' with 'prev()'...?

Anyway... Thank You in advance for any hints... :)

This is how it could look and the variation it has:
  1. <div class="show-for-medium-down">
  2. // top bar code
  3. <nav class="tab-bar">
  4.     <section class="left-small">
  5.         <a class="left-off-canvas-toggle menu-icon" ><span></span></a>
  6.     </section>
  7.     <section class="middle tab-bar-section">
  8.         <h1 class="title">SITE</h1>
  9.     </section>
  10. </nav>
  11. //  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - 
  12.  <aside class="left-off-canvas-menu">

  13.   <ul class="off-canvas-list">

  14.     <li><label>HOME</label></li>
  15.     <li class="has-submenu"><a href="#">GENERAL</a>
  16.         <ul class="left-submenu">
  17.             <li class="back"><a href="#">BACK</a></li>
  18.             <li><a href="index.php">Intro</a></li>
  19.             <li><a href="location.php">Location</a></li>
  20.             <li><a href="gallery.php">Gallery</a></li>
  21.          </ul>
  22.     </li>

  23.     <li><label>MUSIC</label></li>
  24.     <li class="has-submenu"><a href="#">LISTEN</a>
  25.         <ul class="left-submenu">
  26.             <li class="back"><a href="#">ROCK</a></li>
  27.             <li><a href="hendrix.php">Hendrix</a></li>
  28.             <li><a href="clapton.php">Clapton</a></li>
  29.             <li><a href="stones.php">Stones</a></li>
  30.         </ul>
  31.     </li>

  32.     <li><label>COURSES</label></li>
  33.     <li class="has-submenu"><a href="#">WEBDEV</a>
  34.         <ul class="left-submenu">
  35.             <li class="back"><a href="#">BACK</a></li>
  36.             <li><a href="learn.php">Learn PHP</a></li>
  37.         </ul>
  38.     </li>

  39.     <li><a href="contact.php">Contact</a></li>

  40.   </ul>

  41.  </aside>
  42. </div>