gpt4 book ai didi

jquery - jQuery if/else意外 token : punch ({)

转载 作者:行者123 更新时间:2023-12-03 08:11:45 24 4
gpt4 key购买 nike

我有一些如果查询。它必须有点像媒体查询。在某种程度上,它起作用了,但是Grunt打印出了一个错误,称为:

Unexpected token: punc ({).



这是我的jQuery代码段:
$(document).ready(function () {
if ($(window).resize(function () {
if ($(window).width() < 800) {
$('.bxslider').bxSlider({
minSlides: 2,
maxSlides: 2,
moveSlides: 1,
pager: false,
randomStart: true,
auto: true,
autoHover: true,
controls: true,
onSliderLoad: function () {
showSlider();
}
});
}
if ($(window).width() < 480) {
$('.bxslider').bxSlider({
minSlides: 1,
maxSlides: 1,
moveSlides: 1,
pager: false,
randomStart: true,
auto: true,
autoHover: true,
controls: true,
onSliderLoad: function () {
showSlider();
}
});
}
}))
else {
$('.bxslider').bxSlider({
minSlides: 3,
maxSlides: 3,
moveSlides: 1,
pager: false,
randomStart: true,
auto: true,
autoHover: true,
controls: true,
onSliderLoad: function () {
showSlider();
}
});
}
});

最佳答案

考虑到您提供的信息量有限,很难说,但是我很确定这实际上是您想要做的。

$(document).ready(function(){
$(window).resize(function(){
if($(window).width() < 480){
$('.bxslider').bxSlider({
minSlides: 1,
maxSlides: 1,
moveSlides: 1,
pager: false,
randomStart: true,
auto: true,
autoHover: true,
controls: true,
onSliderLoad: function(){
showSlider();
}
});
}
else if($(window).width() < 800){
$('.bxslider').bxSlider({
minSlides: 2,
maxSlides: 2,
moveSlides: 1,
pager: false,
randomStart: true,
auto: true,
autoHover: true,
controls: true,
onSliderLoad: function() {
showSlider();
}
});
}
else {
$('.bxslider').bxSlider({
minSlides: 3,
maxSlides: 3,
moveSlides: 1,
pager: false,
randomStart: true,
auto: true,
autoHover: true,
controls: true,
onSliderLoad: function(){
showSlider();
}
});
}
});
});

关于jquery - jQuery if/else意外 token : punch ({),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23143349/

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