[英]Jquery - missing ; before statement error
i have a minor problem but i dont know how to fix it i made a script with different settings but i receive an error 我有一个小问题,但我不知道如何解决它我做了一个不同设置的脚本,但我收到一个错误
$(function() {
$(".basket").hide();
$(".opened").click(function(){
$(".basket").slideToggle();
$(".opened").toggleClass('active');
});
$(".black-block .showed").click(function(e){
$(".black-block").find(".caption").slideToggle();
$(".showed a").toggleClass('active');
});
$(".carousel").jCarouselLite({
btnNext: "#c1r",
btnPrev: "#c1l",
easing: "easeOutQuad",
visible: 5,
});
var currentSlide = 1;
var currentPage = 0;
$('#slideshow').slides({
preload: true,
preloadImage: 'img/loading.gif',
effect: 'slide',
crossfade: true,
play: 5000,
slideSpeed: 350,
fadeSpeed: 500,
generateNextPrev: true,
generatePagination: false,
animationStart: function(current){
$('').animate({
bottom:-155
},100);
if (window.console && console.log) {
// example return of current slide number
console.log('animationStart on slide: ', current);
};
},
animationComplete: function(current){
$('').animate({
bottom:0
},200);
if (window.console && console.log) {
// example return of current slide number
console.log('animationComplete on slide: ', current);
};
var newPage = Math.floor(currentSlide / 6);
if (newPage > currentPage) { // Page must be greater
$('#c1r').trigger('click');
}
else (newPage < currentPage) { // Page must be less
$('#c1l').trigger('click');
}
currentPage = newPage;
currentSlide = current;
},
slidesLoaded: function() {
$('').animate({
bottom:0
},200);
}
});
According to Firebug the error should be here: 根据Firebug,错误应该在这里:
else (newPage < currentPage) { // Page must be less
$('#c1l').trigger('click');
Since i am out of idea it would be awesome if maybe someone can give ma hint whats wrong. 因为我不知道如果有人可以提出错误的话会很棒。 Thank you in advance.
先感谢您。
change 更改
else (newPage < currentPage) { // Page must be less
to 至
else if (newPage < currentPage) { // Page must be less
You forgot if
keyword after else
and before that conditional statement newPage < currentPage
你忘了
if
else
之后和之前的条件语句newPage < currentPage
else if(newPage < currentPage) {
// Page must be less
$('#c1l').trigger('click');
}
You also have a extra trailing comma here: 你还有一个额外的尾随逗号:
$(".carousel").jCarouselLite({
btnNext: "#c1r",
btnPrev: "#c1l",
easing: "easeOutQuad",
visible: 5,
});
If you use a good ide (I suggest WebStorm), it'll catch these pesky errors for you. 如果你使用一个好的ide(我建议使用WebStorm),它会为你捕获这些讨厌的错误。
You missed an if
: 你错过了一个
if
:
else if(newPage < currentPage)
anyway passing your code on lint reveals multiple warnings you can check them here: http://www.javascriptlint.com/online_lint.php 无论如何在lint上传递你的代码会显示多个警告你可以在这里查看: http : //www.javascriptlint.com/online_lint.php
You've missed an if
keyword after else
: 你已经错过了
if
关键字后面else
:
it is actually else if
instead of if
实际上它不是
else if
而是if
Try: 尝试:
if (newPage > currentPage) { // Page must be greater
$('#c1r').trigger('click');
}
else if (newPage < currentPage) { // Page must be less
$('#c1l').trigger('click');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.