Is there a better fixed scheme for scrolling to the top?

Mobile, PC, Mini Program can all
I have implemented one. The principle is that by listening to the scroll bar, when the element reaches the top, it shows the element of fixed and hides the original element.
but the monitoring of the scroll bar is not sensitive, there will be ghosting, is there a better way to implement it?

Sep.28,2021

I read in a blog post that I also used this to make my own website:

$('-sharpbackTop').click(function (e) {
    e.preventDefault();
    $('html, body').animate({ scrollTop: 0 }, 300);
});
<a id="backTop" href="-sharp">backTop</a>
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-1b36bec-2c045.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-1b36bec-2c045.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?