为什么使用jQuery幻灯片演示不能正常工作? [英] why my slideshow using jQuery is not working?
本文介绍了为什么使用jQuery幻灯片演示不能正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经阅读教程,并实现了它使用的是图像幻灯片jquery..but我无法找出为什么它不工作的实际原因,显示..
我的aspx code
< DIV ID =幻灯片>
< IMG SRC =图标/ 7.JPG级=活动/>
< IMG SRC =图标/ contestpic.PNG/>
< IMG SRC =sgipc / PIC / contestpic.jpg/>
< / DIV>
我的javascript code
函数slideSwitch(){
变量$激活= $('#幻灯片IMG.active');
变量$下一= $ active.next(); $ active.addClass('一个活动'); $ next.css({不透明:0.0})
.addClass(激活)
.animate({不透明:1.0},1000,函数(){
$ active.removeClass('主动一个活动');
});
} $(函数(){
的setInterval(slideSwitch(),5000);
});
我的CSS
#slideshow {
位置:相对;
高度:350像素;
边框:1px的固体绿色;
}#slideshow IMG {
位置:绝对的;
顶部:0;
左:0;
的z-index:8;
}#slideshow IMG.active {
的z-index:10;
}#slideshow IMG.last活跃{
的z-index:9;
}
解决方案
错误
$(函数(){
的setInterval(slideSwitch(),5000);
});
右
$(函数(){
的setInterval(slideSwitch,5000);
});
i have read a tutorial and implemented it to show a image slide using jquery..but i couldn't find out the actual reason why it is not working.. my aspx code
<div id="slideshow">
<img src="icon/7.jpg" class="active" />
<img src="icon/contestpic.PNG" />
<img src="sgipc/pic/contestpic.jpg" />
</div>
my javascript code
function slideSwitch() {
var $active = $('#slideshow IMG.active');
var $next = $active.next();
$active.addClass('last-active');
$next.css({ opacity: 0.0 })
.addClass('active')
.animate({ opacity: 1.0 }, 1000, function () {
$active.removeClass('active last-active');
});
}
$(function () {
setInterval("slideSwitch()", 5000);
});
my css
#slideshow {
position:relative;
height:350px;
border:1px solid green;
}
#slideshow IMG {
position:absolute;
top:0;
left:0;
z-index:8;
}
#slideshow IMG.active {
z-index:10;
}
#slideshow IMG.last-active {
z-index:9;
}
解决方案
WRONG
$(function () {
setInterval("slideSwitch()", 5000);
});
RIGHT
$(function () {
setInterval(slideSwitch, 5000);
});
这篇关于为什么使用jQuery幻灯片演示不能正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文