javascript - Single Page Menu, link highlights undefined is not an object for offset.top -


so i'm working on 1 page menu using guide here: http://callmenick.com/post/single-page-site-with-smooth-scrolling-highlighted-link-and-fixed-navigation

html

<div class="um-member-nav-menu">         <ul>             <li><a href="#car">car</a></li>             <li><a href="#about">about</a></li>             <li><a href="#students">students</a></li>             <li><a href="#reviews">reviews</a></li>             <li><a href="#social">social</a></li>         </ul>     </div> <div class="um-member-profile-content">     <div id="car">content</div>     <div id="about">content</div>     <div id="students">content</div>     <div id="reviews">content</div> </div> 

js

     function profileheader() {          /**           * part "fixed navigation after scroll" functionality          * use jquery function scroll() recalculate our variables           * page scrolled/          */         $(window).scroll(function() {             var window_top = $(window).scrolltop() + 12; // "12" should equal margin-top value nav.stick             var div_top = $('.um-member-nav-menu').offset().top;          });          /**          * part causes smooth scrolling using scrollto.js          * target tags inside nav, , apply scrollto.js it.          */         $(".um-member-nav-menu ul li a").click(function(evn) {             evn.preventdefault();             $('html,body').scrollto(this.hash, this.hash);         });          /**          * part handles highlighting functionality.          * use scroll functionality again, array creation ,           * manipulation, class adding , class removing, , conditional testing          */         var achildren = $(".um-member-nav-menu li").children(); // find children of list items         var aarray = []; // create empty aarray         (var = 0; < achildren.length; i++) {             var achild = achildren[i];             var ahref = $(achild).attr('href');             aarray.push(ahref);          } // loop fills aarray attribute href values          $(window).scroll(function() {             var windowpos = $(window).scrolltop(); // offset of window top of page             var windowheight = $(window).height(); // height of window             var docheight = $(document).height();              (var = 0; < aarray.length; i++) {                 var theid = aarray[i];                  var divpos = $(theid).offset().top; // offset of div top of page                 var divheight = $(theid).height(); // height of div in question                 if (windowpos >= divpos && windowpos < (divpos + divheight)) {                     $("a[href='" + theid + "']").addclass("active");                 } else {                     $("a[href='" + theid + "']").removeclass("active");                 }             }              if (windowpos + windowheight == docheight) {                 if (!$(".um-member-nav-menu li:last-child a").hasclass("active")) {                     var navactivecurrent = $(".um-member-nav-menu li a.active").attr("href");                     $("a[href='" + navactivecurrent + "']").removeclass("active");                     $(".um-member-nav-menu li:last-child a").addclass("active");                 }             }         });     }; 

so code works, i'm getting hundreds of js errors in console stating "typeerror: undefined not object (evaluating '$(s).offset().top')"

i've echoed out 'theid' , it's getting section id correctly. seems passing 's'?

live link: http://beta.passpilot.co.uk/user/ed-craddock/

any awesome!


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -