gpt4 book ai didi

javascript - 窗口调整大小条件

转载 作者:行者123 更新时间:2023-11-28 17:40:03 25 4
gpt4 key购买 nike

我正在尝试创建响应式图像 slider ,但我不断遇到此错误:

error occured: Name cannot begin with the ' ' character, hexadecimal value 0x20. Line 422, position 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');}
});

最佳答案

似乎您在调整大小时重新实例化了插件。

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

$(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');}
});
});

我在 the documentation 中获取了信息,您所需要了解的有关您使用的产品的所有信息都应该在此处。

关于javascript - 窗口调整大小条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48123452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com