我有一个小问题,但我不知道如何修复它我做了一个不同设置的脚本,但我收到一个错误
$(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);
}
});
根据Firebug,错误应该在这里:
else (newPage < currentPage) { // Page must be less
$('#c1l').trigger('click');
由于我不知道如果有人能给出提示错误的话会很棒。提前谢谢。
答案 0 :(得分:2)
更改
else (newPage < currentPage) { // Page must be less
到
else if (newPage < currentPage) { // Page must be less
答案 1 :(得分:1)
您在if
之后和该条件语句else
newPage < currentPage
个关键字
else if(newPage < currentPage) {
// Page must be less
$('#c1l').trigger('click');
}
答案 2 :(得分:1)
此处还有一个额外的尾随逗号:
$(".carousel").jCarouselLite({
btnNext: "#c1r",
btnPrev: "#c1l",
easing: "easeOutQuad",
visible: 5,
});
如果你使用一个好的ide(我建议使用WebStorm),它会为你捕捉这些讨厌的错误。
答案 3 :(得分:0)
您错过了if
:
else if(newPage < currentPage)
无论如何在lint上传递代码会显示多个警告,您可以在此处查看它们: http://www.javascriptlint.com/online_lint.php
答案 4 :(得分:0)
if
之后您错过了else
个关键字:
实际上是else if
而不是if
尝试:
if (newPage > currentPage) { // Page must be greater
$('#c1r').trigger('click');
}
else if (newPage < currentPage) { // Page must be less
$('#c1l').trigger('click');
}