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