About the use of scrollTop

problem description

use $(".scroll _ center"). ScrollTop (0) in our angular project; failed to top the scroll bar, which is a pop-up scroll bar

the environmental background of the problems and what methods you have tried

this element is a pop-up box, and then solved with a timer, you can set it to the top, but the loading mode of this js is somewhat unknown. Which god can answer it? thank you very much

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

    $timeout(function(){
        $(".dialog_center").scrollTop(0);
    })

what result do you expect? What is the error message actually seen?

Apr.05,2021

timeout is added to the task queue, delaying execution.
may be that your pop-up box has an animation effect, so that the element $('.pop _ center') is not available the first time. You can try to remove the timeout and print out $('.blank _ center') to see if it is empty.


your problem flow is not fully described and can only be guessed.

  1. using $('.rendering _ center'). ScrollTop (0) does not work, most likely because there is no such object as class _ center on the page at this time, and the reason is that the process of rendering dom on the page is not finished yet.
  2. is placed in timeout, and it will be executed immediately after the current process is idle (Angular should have done Dom rendering work before). At this time, all the page elements can be found and manipulated directly, so it can achieve the desired effect
  3. .
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3604e-2bfe9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3604e-2bfe9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?