2012-10-01 59 views
1

我在jQuery循環幻燈片中有一個透明PNG。在翻轉時,它會從圖像A變爲B.在鼠標移出時,它會返回到A.但是,之後的任何翻轉都不會重複此漸變。任何想法? 感謝jquery循環插件 - 懸停/鼠標幻燈片

<script type="text/javascript"> 
    $(document).ready(function(){ 
      $('#picroll').cycle({        
       timeout:.2, 
       delay: 0, 
     fx: 'fade', 
     continuous: false, 
       speed: 300, 
       autostop: 1 
     }).cycle("pause").hover(function() { 
       $(this).cycle('resume'); 
     },function(){ 
       $(this).cycle('pause'); 
     $(this).cycle('resume'); 
    }) 
    .mouseleave(function(){ 
     $(this).cycle(0, 'fade').cycle('play'); 
     }); 
    }); 
</script> 

    <div id="picroll"><a href="#"><img src="images/group/PictureA.png" width="114" height="330"/> 
    <img src="images/group/PictureB.png" width="114" height="330" /></div> 
+0

懸停函數被調用? – njzk2

+0

懸停功能在#picroll上。它在頁面加載時啓動,然後在懸停時恢復。這是否回答你的問題。不太熟悉javascript ... – flightrecorder

+0

你確定它被稱爲?如果你從JS控制檯調用簡歷,它是否工作? – njzk2

回答

1

使用這個代替:

$("#picroll").mouseover(' 
    $("#picroll:nth-child(1)").fadeOut(500); 
    $("#picroll:nth-child(2)").fadeIn(500); 
'); 
$("#picroll").mouseout(' 
    $("#picroll:nth-child(1)").fadeIn(500); 
    $("#picroll:nth-child(2)").fadeOut(500); 
'); 
+0

謝謝!雖然我得到一個語法錯誤,我不知道它在哪裏。 – flightrecorder

+0

我編輯了我的代碼;犯了一個錯誤。如果你可以給圖像自己的id而不是使用第n個子選擇器會更好。 – Mooseman