我有自己的jQuery轮播,突然它停止在Xmas前夕工作,我不知道为什么。基本的语义结构很简单:
<section class = "slideshow">
<div id = "slides">
<ul>
<li id = "slide_1">
<div class = "slide">
<div >
content for slide 1
</div>
</div>
</li>
<li>
<div class = "slide">
<div >
content for slide 2
</div>
</div>
</li>
</ul>
</div>
</section>
<input type = "button" value = ">>" id = "forward"/>
相应的jQuery是:
$('#forward').click(slideup);
function slideup()
{
var item_width = $('#slides li').outerWidth(true);
var old_left = parseInt($('#slides ul').css('left'));
var left_indent = old_left - item_width;
$('#slides ul').animate({'left':left_indent},"slow", function(){
$('#slides li:last').after($('#slides li:first'));
$('#slides ul').css({'left':0});
} );
}
但没有任何事情发生。这是一个js小提琴,它也捕获了CSS:
谢谢!
P.S:Merry Xmas Stackoverflowers :)
答案 0 :(得分:2)
尝试动画margin-left:
$('#slides ul').animate({'left':left_indent},"slow", function(){
到
$('#slides ul').animate({'margin-left':left_indent},"slow", function(){