如何使用jquery和php链接到同一页面中的特定部分?

如何使用jquery和php链接到同一页面中的特定部分?,php,jquery,html,hyperlink,href,Php,Jquery,Html,Hyperlink,Href,我知道要链接到同一页面中的某个部分,如: <a href='#A'>A</a> <a name='A'>Here is A</a> 没有时间查看所有代码,但不能使用scrollTop方法? 请参阅。要使用jQuery滚动到页面中的特定ID,请使用 $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow'); 您也可以在url中指定锚定 <a href="your-

我知道要链接到同一页面中的某个部分,如:

<a href='#A'>A</a>

<a name='A'>Here is A</a>

没有时间查看所有代码,但不能使用scrollTop方法?
请参阅。

要使用jQuery滚动到页面中的特定ID,请使用

$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');

您也可以在url中指定锚定

<a href="your-page.html#k" />
当您单击链接时,您将被带到该页面,文档将自动滚动到

$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
<a href="your-page.html#k" />