📜  jquery only on mobile - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:17.243000             🧑  作者: Mango

代码示例1
$(document).ready(function () {
    $(window).on("resize", function (e) {
        checkScreenSize();
    });

    checkScreenSize();

    function checkScreenSize(){
        var newWindowWidth = $(window).width();
        if (newWindowWidth < 481) {
            $('.right').insertBefore('.left');
        }
        else
        {
            $('.left').insertBefore('.right');
        }
    }
});