Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  1] [ 1]  / answers: 1 / hits: 122749  / 9 Years ago, thu, march 5, 2015, 12:00:00

I want to scroll to the top of the page after getting an ajax call response using angularjs. Basically, I am displaying alert messages on top of the page and I want to focus the alert message as the ajax response received.



Thanks


More From » jquery

 Answers
19

You can use



$window.scrollTo(x, y);


where x is the pixel along the horizontal axis and y is the pixel along the vertical axis.




  1. Scroll to top



    $window.scrollTo(0, 0);

  2. Focus on element



    $window.scrollTo(0, angular.element('put here your element').offsetTop);   



Example



Update:



Also you can use $anchorScroll



Example


[#67563] Tuesday, March 3, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
janeth

Total Points: 498
Total Questions: 91
Total Answers: 89

Location: Malaysia
Member since Wed, May 11, 2022
2 Years ago
;