Interactive online courses HTML Academy
2026-03-09 12:29 Diff

We added the onclick event handler to the script and made sure that the page scrolls back to the beginning when the arrow button is clicked. The button itself does not disappear, although when the user is at the very top of the page, there is no longer any need to show it.

In order to hide the button, we need to remove the classshown from it. This needs to be done if the vertical scroll value is not more than 200px. We already have a conditional construct that checks the scroll value and adds a class to the button if it scrolls more than 200px. Add the alternative branchelse to the conditional statement: if the statement is false, then use the classList.remove method to remove the shown class from the button.

After that, make sure that the page scrolls back to the top when you click the “Up” button and that the button itself is hidden.