jQuery动画函数在我的jQuery滑块中不起作用
jQuery Animation function is not working in my jquery slider
我是jQuery和web开发的初学者。我对jquery的animate函数有一些问题。我还在这里制作了一把小提琴:-jsFiddle下面是脚本的主要功能:-我还没有添加完整的脚本,因为这可能是css的问题,因为我是一个初学者
$(document).ready(function(){
var showImage=function(photoObject,direction,maincontainer){
alert("I am Also Called");
animating=true;
if(direction=="next"){
maincontainer.animate({"left":"1080px"},slideshowspeed,linear,function(){
alert("I am also called");
$("#slider_caption").css({
"background-image" : "photoObject.image"
});
});
}
};
});
您有很多语法错误:
}
关闭错误- 不检查
maincontainer
是否存在
var slideshowspeed=6000;
//variable to store the images we need to set as background
//which also includes some text and url's.
//speed of the automatic slideshow
var photos = [
{
"title" : "Stairs",
"image" : "image1.jpg",
"firstline" : "Going on",
"secondline" : "vacation?"
}, {
"title" : "Office Appartments",
"image" : "image2.jpg",
"firstline" : "Or still busy at",
"secondline" : "work?"
}, {
"title" : "Mountainbiking",
"image" : "image3.jpg",
"firstline" : "Get out and be",
"secondline" : "active"
}, {
"title" : "Mountains Landscape",
"image" : "image1.jpg",
"firstline" : "Take a fresh breath of",
"secondline" : "nature"
}, {
"title" : "Italian pizza",
"image" : "image2.jpg",
"firstline" : "Enjoy some delicious",
"secondline" : "food"
}
];
$(document).ready(function(){
$("#next").click(function(){
alert("dash is a strategical boy");
navigate("next");
});
});
$("#prev").click(function(){
alert("dash is a strategical boy from prev");
navigate("back");
});
var currentImg=0;
animating=false;
var navigate = function(direction) {
if(animating) {
return;
}
if(direction == "next") {
currentImg++;
alert("I am inside Next");
if(currentImg == photos.length + 1) {
currentImg = 1;
}
} else {
currentImg--;
alert("I am inside prev");
if(currentImg === 0) {
currentImg = photos.length;
}
}
var maincontainer=$("#slider_caption");
showImage(photos[currentImg - 1],direction);
};
var showImage = function(photoObject,direction,maincontainer){
alert("I am Also Called");
animating = true;
if (direction == "next") {
if (maincontainer)
maincontainer.animate({"left":"1080px"},slideshowspeed,linear,function(){
alert("I am also called");
$("#slider_caption").css({
"background-image" : "photoObject.image"
});
});
}
};
相关文章:
- 自动完成 jquery 不起作用
- 悬停时的Jquery不起作用
- 使用DateTimePicker插件的JQuery不起作用
- 无限滚动jquery不起作用
- 角度2触发器'单击'使用jquery不起作用
- 在 jQuery 不起作用的情况下迭代变量
- 切换下 jquery 不起作用
- 简单的jquery不起作用,并返回错误
- 等效于getElementbyName的jQuery不起作用
- Jquery不起作用,但我想一切都好
- 当按钮从ajax调用时,jquery不起作用
- 在jQuery不起作用的情况下阻止表单提交
- 为什么这个jquery不起作用
- 带有变量选择器的 Jquery 不起作用
- 简单的JavaScript/jQuery不起作用
- Wordpress jquery不起作用(计算系统)
- Django 模板内联 jQuery 不起作用
- 提示计算器 jquery 不起作用
- 追加 jquery 不起作用
- 正则表达式 jQuery 不起作用