Programmatically scroll to an Anchor Tag

前端 未结 8 1592
孤独总比滥情好
孤独总比滥情好 2020-11-28 07:21

Consider the following code:

GoTo Label2
... [content here] ...
More content


        
8条回答
  •  醉话见心
    2020-11-28 07:21

    you can just open the new URL with the name appended, for instance http://www.example.com/mypage.htm#label2

    In JavaScript,

    location.href = location.href + '#label2';
    

提交回复
热议问题