I've been trying to implement a back to top button on a horizontally scrolling page. However, I'm encountering difficulties in adding or removing the necessary class to show or hide the button.
Here's the JavaScript code I'm using:
$(window).scroll(function() {
var scroll = $(window).scrollTop();
//console.log(scroll);
if (scrollX >= 50) {
//console.log('a');
$(".btt").addClass("show");
} else {
//console.log('a');
$(".btt").removeClass("hide");
}
});
Could someone advise me on what steps I should take next?
Thank You