2010-10-19 60 views
0

得到一个jQuery脚本工作,我在我的网页上rotatePics jQuery脚本:无法在Firefox

$(document).ready(function(){ 
    rotatePics(1); 
}); 

function rotatePics(currentPhoto) { 
    var numberOfPhotos = $('.photos img').length; 
    currentPhoto = currentPhoto % numberOfPhotos; 

    $('.photos img').eq(currentPhoto).fadeOut(function() { 
    // re-order the z-index 
    $('.photos img').each(function(i) { 
     $(this).css(
     'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos 
    ); 
    }); 
    $(this).show(); 
    setTimeout(function() {rotatePics(++currentPhoto);}, 5000); 
    }); 
} 

我在主页的我的头部分以下内容:

<script type="text/javascript" src="js/jquery-1.4.min.js"></script> 
<script type="text/javascript" src="js/script.js"></script> 

这里在网页的HTML:

<div id="imageanimation"> 
    <table id="picturetable"> 
    <tr> 
     <td class="photos"></td> 
     <td class="photos"></td> 
     <td class="photos"></td> 
     <td class="photos"></td> 
    </tr> 
    </table> 
</div> <!-- close imageanimation div --> 

<!-- Your website would not let me upload images --> 

这里是CSS:

#picturetable { 
float:left; 
height:212px; 
margin:0 auto; 
position:relative; 
left:15px; 
z-index:-1; 
} 

.photos img { 
    position: absolute; 
} 

.photos { 
    width: 212px;; 
    height: 212px; 
    overflow: hidden; 
    padding:5px; 
    padding-top:10px; 
    padding-bottom:10px; 
} 

我在做什么错?

+1

首先需要说明什么是错的,什么是不工作的,你得到一个错误? – 2010-10-19 15:29:29

+0

那么当你尝试这个时,你会得到什么错误或行为? – JohnFx 2010-10-19 15:30:03

+1

指向显示问题的页面的链接可能会为您带来更快的结果。 – 2010-10-19 15:30:40

回答

0

尝试移动

function rotatePics(currentPhoto) { 
    ... 
} 

$(document).ready(function(){ 
    rotatePics(1); 
}); 

之前此外,安装萤火虫插件,看看它是否给任何错误。

+0

假设JavaScript是在同一文件中,在函数声明顺序并不重要。 – 2010-10-19 15:33:08

0

您正在试图通过位置,但EQ()选择需要选择。 你可能是指

$('.photos:eq('+currentPhoto+') img')