jQuery Syntax error, unrecognized expression -


i have script updates fixed menu user's position scroll down page. working on front-end error free, have started working on wordpress integration getting bizarre error message having trouble understanding.

one loading page fine, scroll down error appears.

here jsfiddle. http://jsfiddle.net/2k4eq/ seems related full url, works #whatwedo.

syntax error, unrecognized expression: http://localhost:8888/sitename/#whatwedo 

from jquery

 sizzle.error = function( msg ) {     throw new error( "syntax error, unrecognized expression: " + msg );  }; 

thank you!

// update menu position on scroll     $(function() {         function updatemenu() {              var lastid,                 mainmenu = $("#main-menu ul"),                 mainmenuinnerheight = mainmenu.outerheight(),                 mainmenuitems = $("#main-menu.navigation ul").find(".section-item a"),                 sliderbuttons = $("#call-to-actions "),                 sliderlinks = sliderbuttons.find("a.button.white"),                           // anchors relating links                                     scrollitems = mainmenuitems.map(function(){                   var item = $(this).attr("href");                   if (item.length) { return item; }                 });                 console.log(scrollitems);               mainmenuitems.bind("click",scrolldown);             sliderlinks.bind("click",scrolldown);              function scrolldown(e){                 e.preventdefault();                   var href = $(this).attr("href"),                     offsettop = href === "#" ? 0 : $(href).offset().top;                  $("html, body").stop().animate({                      scrolltop: offsettop                 }, 600);                  $("#main-mobile-menu").hide();              }                 $(window).scroll(function(){                 var fromtop = $(this).scrolltop()+mainmenuinnerheight;                  var cur = scrollitems.map(function(){                     if ($(this).offset().top < fromtop)                         return this;                 });                    cur = cur[cur.length-1];                  var id = cur && cur.length ? cur[0].id : "";                  if (lastid !== id) {                     lastid = id;                                  mainmenuitems                         .parent().removeclass("active")                         .end().filter("[href=#"+id+"]").parent().addclass("active");                 }                                });           }          updatemenu();            $(window).resize(function(){             updatemenu();         });     }); 

the issue caused trying use full url other hash , id. splitting results , using anchor ensured script still ran, meant navigating correction homepage section page still worked. helped got me thinking , lead me down right path.

$(function() { function updatemenu() {      var lastid,         mainmenu = $("#main-menu ul"),         mainmenuinnerheight = mainmenu.outerheight(),         mainmenuitems = $(".home .navigation ul").find("li.section-item a"),                  scrollitems = $(".navigation li.section-item a").map(function() {             itemssplit = $(this).attr("href").split("#");             itemhref = $("#" + itemssplit[1]);              return itemhref;         });           mainmenuitems.bind("click",scrolldown);      function scrolldown(e){         e.preventdefault();           var href = $(this).attr("href").split("#"),             hrefsplit = href[1],              offsettop = $("#" + hrefsplit).offset().top;                  $("html, body").stop().animate({              scrolltop: offsettop         }, 600);     }         $(window).scroll(function(){          var fromtop = $(this).scrolltop()+mainmenuinnerheight;          var cur = scrollitems.map(function(){                            if ($(this).offset().top < fromtop)                  return this;         });          cur = cur[cur.length-1];          var id = cur && cur.length ? cur[0].id : "";          if (lastid !== id) {             lastid = id;              mainmenuitems                 .parent().removeclass("active")                 .end().filter("[href$="+id+"]").parent().addclass("active");         }                        }); }  updatemenu();    $(window).resize(function(){     updatemenu(); }); }); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -