jquery - animate scrolling matching the name not working fine -


$("a.scroll").click(function(){      if(this.hash){         //get rid of hash         var hash = this.hash.substr(1);          //get position of <a name>         var $toelement = $("a[name="+hash+"]");         var toposition = $toelement.offset().top - 250;          //scroll/animate element         $("body,html").animate({              scrolltop : toposition          },1000,"easeoutexpo");          return false;     } });  if(location.hash){     var hash = location.hash;     window.scroll(0,0);     $("a[href="+hash+"]").click(); } 

when trying match name string , scrolling location hiding behind header, header fixed.. on scrolling..

and facing problem when resize window, header takes space , scrolling hides content behind.. how fix it//

the <a> element doesn't have hash member. check console errors before posting. need href attribute's content. might needing this:

$("a.scroll").click(function() {   var href = $(this).attr("href");   if (href.indexof("#") === 0) {     //get rid of hash     var hash = href.substr(1);     //get position of <a name>     var $toelement = $("a[name=" + hash + "]");     var toposition = $toelement.offset().top - 250;     //scroll/animate element     $("body,html").animate({       scrolltop: toposition     }, 1000, "easeoutexpo");     return false;   } }); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -