title: What is wrong with this jquery function?
body: <p>I am using jquery to scroll to an anchor.... It works fine with a html button calling the function...</p>
  
  <p>But when i call it from server side i get the id but it doesn't seem to work for me...</p>
  
  <pre><code>LinkButton lb1 = (LinkButton)sender;
  ScriptManager.RegisterClientScriptBlock(lb1, typeof(LinkButton),
   "scroll","goToByScroll('myAnchor')", true);
  </code></pre>
  
  <p>And my function is,</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
   function goToByScroll(id) {alert(id);
     $('html,body').animate({ scrollTop: $("#" + id).offset().top }, 'slow');
     }
   &lt;/script&gt;
  </code></pre>
  
  <p>I got the error <code>$("#" + id).offset() is null</code></p>
  
  <p>I get the alert id of my anchor but why doesn't it work....</p>
  
  <p>Here is my anchor...</p>
  
  <p><code>&lt;a name="myAnchor" id="myAnchor"&gt;&lt;/a&gt;</code></p>
  
  <p>Its working perfectly in a html button,</p>
  
  <p><code>&lt;input id="Button1" type="button" value="button" onclick="goToByScroll('myAnchor');"/&gt;</code></p>