Scroll to a certain element of the current page in Angular 4

前端 未结 3 535
独厮守ぢ
独厮守ぢ 2020-12-19 06:16

Upon clicking a button (which is bottom of the page), I want to go to a certain element (in my case, #navbar) which is in the top of the current page, but I don\'t know how

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-19 06:39

    I know, you want to scroll to a specific element in the page. But, if the element is in the top of the page, then you can use the following:

    window.scrollTo(0, 0);
    

提交回复
热议问题