window.addEventListener("load", () => {
    const $buttonScrollTop = $("#btnScrollTop");

    const handleDisplayBtn = () => {
        if (window.scrollY > 300) {
            $buttonScrollTop.fadeIn();
        } else {
            $buttonScrollTop.fadeOut();
        }
    };

    $buttonScrollTop.on("click", () => {
        window.scroll({
            top: 0,
            left: 0,
            behavior: "smooth",
        });
    });

    window.addEventListener("scroll", () => {
        handleDisplayBtn();
    });

    handleDisplayBtn();
});
