2010-10-19 67 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')