Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在特定大小的屏幕中禁用javascript功能_Javascript_Html_Css - Fatal编程技术网

在特定大小的屏幕中禁用javascript功能

在特定大小的屏幕中禁用javascript功能,javascript,html,css,Javascript,Html,Css,我想在特定大小的屏幕上禁用javascript函数,并在特定大小的屏幕上启用它 这是我的密码: $(document).ready(function(){ $("#moveleft").click(function(){ if ($(window).width() < 768) { $('.box__image').animate({'left' : "-=330px"}); }

我想在特定大小的屏幕上禁用javascript函数,并在特定大小的屏幕上启用它

这是我的密码:

$(document).ready(function(){
    $("#moveleft").click(function(){
        if ($(window).width() < 768) {
            $('.box__image').animate({'left' : "-=330px"});
        }
    });
});
$(文档).ready(函数(){
$(“#向左移动”)。单击(函数(){
如果($(窗口).width()<768){
$('.box_uuimage')。设置动画({'left':“-=330px”});
}
});
});

您可以收听
窗口的大小更改事件

$(document).ready(function() {

  $(window).on('resize', function() {

    if ($(this).width() < 768) {
      $("#moveleft").click(function() {
        $('.box__image').animate({
          'left': "-=330px"
        });
      });
    } else {
      $("#moveleft").off('click')
    }

  });

});
$(文档).ready(函数(){
$(窗口).on('resize',function()){
if($(this).width()<768){
$(“#向左移动”)。单击(函数(){
$('.box\u图像')。设置动画({
“左”:“-=330px”
});
});
}否则{
$(“#向左移动”)。关闭('单击')
}
});
});

请帮助我,它只在我使用切换设备工具栏时起作用。如何区分手机或pc屏幕的大小,