【问题标题】:How can i disable jquery function on max-width 768px?如何在最大宽度 768px 上禁用 jquery 功能?
【发布时间】:2020-01-17 06:39:47
【问题描述】:

我是 JavascriptJquery 的新手。我需要帮助,我已经阅读了很多解决方案,但我无法解决这个问题。

我只是无法正确使用语法。我需要这个scroll button not to be shown at all, on max-width 768px

谢谢!

$(document).ready(function () {
    $(window).scroll(function () {
        if ($(this).scrollTop() > 140) {
            $('#scroll-top-button').fadeIn();
        } else {
            $('#scroll-top-button').fadeOut();
        }
    });

    $('#scroll-top-button').click(function (e) {
        e.preventDefault();
        $('html, body').animate({ scrollTop: 0 }, 800);
    });
});

【问题讨论】:

    标签: javascript jquery css scroll width


    【解决方案1】:

    您是否尝试过在普通的旧 CSS 中使用断点隐藏按钮?

    @media only screen and (max-width: 768px) {
        #scroll-top-button {
            display: none;
        }
    }
    

    【讨论】:

    • 不,它没有工作,但可见性:隐藏工作。 Tnx 科迪。
    猜你喜欢
    • 1970-01-01
    • 2020-02-13
    • 1970-01-01
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多