Javascript 窗口大小调整条件

Javascript 窗口大小调整条件,javascript,jquery,xslt,responsive-design,Javascript,Jquery,Xslt,Responsive Design,我正在尝试创建一个响应图像滑块,但始终遇到以下错误: 出现错误:名称不能以“”字符、十六进制值0x20开头。第422行,位置26 每当我尝试为窗口大小调整添加条件时。问题似乎来自条件语句,但如何解决它?脚本在xslt文件中包含脚本标记。这是我的密码: $(document).ready(function() { $("#carousel").waterwheelCarousel({ forcedImageWidth: 700, forcedImageHeight: 555,

我正在尝试创建一个响应图像滑块,但始终遇到以下错误:

出现错误:名称不能以“”字符、十六进制值0x20开头。第422行,位置26

每当我尝试为窗口大小调整添加条件时。问题似乎来自条件语句,但如何解决它?脚本在xslt文件中包含脚本标记。这是我的密码:

$(document).ready(function() {
  $("#carousel").waterwheelCarousel({
    forcedImageWidth: 700,
    forcedImageHeight: 555,
    separation: 500
  });
});
$(window).resize(function(){
  if(window.innerWidth < 1024){
    $("#carousel").waterwheelCarousel({
      forcedImageWidth: 400,
      forcedImageHeight: 255,
      separation: 100
    });
  }else{alert('hi');}
});
$(文档).ready(函数(){
$(“旋转木马”)。水车转盘({
forcedImageWidth:700,
forcedImageHeight:555,
分离:500
});
});
$(窗口)。调整大小(函数(){
如果(window.innerWidth<1024){
$(“旋转木马”)。水车转盘({
forcedImageWidth:400,
forcedImageHeight:255,
间隔:100
});
}else{alert('hi');}
});

看起来您在调整大小时重新实例化了插件

但这不是正确的方法。。。。您必须使用新选项“重新加载”

$(document).ready(function() {
  //Assign a variable to it on instantiation
  var carousel = $("#carousel").waterwheelCarousel({
    forcedImageWidth: 700,
    forcedImageHeight: 555,
    separation: 500
  });

  $(window).resize(function(){
    if(window.innerWidth < 1024){
      carousel.reload({
        forcedImageWidth: 400,
        forcedImageHeight: 255,
        separation: 100
      });
    }else{alert('hi');}
  });
});
$(文档).ready(函数(){
//在实例化时为其分配一个变量
变量转盘=$(“#转盘”)。水车转盘({
forcedImageWidth:700,
forcedImageHeight:555,
分离:500
});
$(窗口)。调整大小(函数(){
如果(window.innerWidth<1024){
旋转木马({
forcedImageWidth:400,
forcedImageHeight:255,
间隔:100
});
}else{alert('hi');}
});
});

我把这些信息带了进来,你所需要知道的关于你所使用的产品的信息应该都在这里。

看起来你在resize上重新实例化了这个插件

但这不是正确的方法。。。。您必须使用新选项“重新加载”

$(document).ready(function() {
  //Assign a variable to it on instantiation
  var carousel = $("#carousel").waterwheelCarousel({
    forcedImageWidth: 700,
    forcedImageHeight: 555,
    separation: 500
  });

  $(window).resize(function(){
    if(window.innerWidth < 1024){
      carousel.reload({
        forcedImageWidth: 400,
        forcedImageHeight: 255,
        separation: 100
      });
    }else{alert('hi');}
  });
});
$(文档).ready(函数(){
//在实例化时为其分配一个变量
变量转盘=$(“#转盘”)。水车转盘({
forcedImageWidth:700,
forcedImageHeight:555,
分离:500
});
$(窗口)。调整大小(函数(){
如果(window.innerWidth<1024){
旋转木马({
forcedImageWidth:400,
forcedImageHeight:255,
间隔:100
});
}else{alert('hi');}
});
});

我把信息放进去了,你所需要知道的关于你所使用的产品的所有信息都应该放在这里。

我不明白你为什么要包含
xslt
标签。请添加相关信息或删除标记。“祝你好运!”谢尔特说,因为我不知道这是否会带来不同。标记是相关的。我不明白为什么要包含
xslt
标记。请添加相关信息或删除标记。“祝你好运!”谢尔特说,因为我不知道这是否会带来不同。标签是相关的。