The issue pertains to the length of the code used for scrolling up the page upon button click.
<div class="back-to-top">
<a href="#top">Back to Top</a>
</div>
<hr>
</div>
<script>
document.getElementById('back-to-top').addEventListener('click', () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
</script>
I found the current code for scrolling up the page upon button click to be somewhat lengthy. Any suggestions for a more concise implementation?
New contributor
Shenil Deneth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.