0

This webpage http://www.eboxlab.net/ has a menu on the left side. What I need to achieve is to be able to go to a page section when the respective menu option is pressed. Here is my code (pretty sure it's quite bad, but I will clean it up later, after I make it work):

 navigateMe();
navInit = 1;
navNext = 2;
function navigateMe() {
    step = jQuery('ul#navigation li').size();
    looper = setInterval(function(){
        if(navNext > step + 1) {
            navInit = 1;
            navNext = 1;
        }
      var refLink = jQuery('ul#navigation li:nth-child(' + navInit + ') a').attr('href').replace('#', '');
      var divLink = jQuery("div[id='" + refLink + "']").offset().top;
      jQuery('ul#navigation li:nth-child(' + navInit + ') a').on('click', function() {
         jQuery('html, body').animate({
             scrollTop: divLink
            }, 500); 
      });
      navInit = navNext;
      navNext = navNext + 1;

    }, 0);

}

However the problem is that it only works once. After you click menu once, it doesn't slide up or down anymore. Please tell me what's wrong with it. Many thanks in advance.

Serge Eremeev
  • 120
  • 1
  • 2
  • 10
  • works 100% in Safari and Firefox although the animation in firefox is a bit laggy, but that's expected in firefox – samrap Sep 20 '13 at 00:47
  • 1
    i realized why it wasn't working in about 10 minutes after I've posted the question((( SO yea, it's fixed now (and firefox is a bit buggy as you said) – Serge Eremeev Sep 20 '13 at 00:54

0 Answers0