i have used onclick event
scrolltoTop= async () => {
window.scrollTo(0,0)
}
but it takes more time to go top so how to go top dyrect using javascript, and if it is not support than how to fast scroll?
i have used onclick event
scrolltoTop= async () => {
window.scrollTo(0,0)
}
but it takes more time to go top so how to go top dyrect using javascript, and if it is not support than how to fast scroll?
Instead of window.scrollTo(xCoord, yCoord);
you can use scrollIntoView()
like so:
<html>
<body>
<div id="top"></div>
.....
</body>
</html>
<script>
document.getElementById("top").scrollIntoView();
</script>