2016-04-02 11 views
0

我有一堆5個圖像,我在循環懸停。通過懸停時的圖像循環,並停止與上次看到的圖像

http://jsfiddle.net/9kxw7wpg/1/

jQuery(function($){ 

    // Cycle plugin 
    $('.slides').cycle({ 
     fx:  'none', 
     speed: 1, 
     timeout: 500 
    }).cycle('pause'); 

    // Pause & play on hover 
    $('.slideshow-block').hover(function(){ 
     $(this).find('.slides').addClass('active').cycle('resume'); 
    }, function(){ 
     $(this).find('.slides').removeClass('active').cycle('pause'); 
    }); 

}); 

我現在要實現的是鼠標移開時不是黑色的背景應該再是可見的,但是這被視作懸停最後一張圖像。

回答

0

一般而言,您可以刪除removeClass函數。

jQuery(function($){ 

    // Cycle plugin 
    $('.slides').cycle({ 
    fx:  'none', 
    speed: 1, 
    timeout: 500 
    }).cycle('pause'); 

    // Pause & play on hover 
    $('.slideshow-block').hover(function(){ 
    $(this).find('.slides').addClass('active').cycle('resume'); 
    }, function(){ 
    $(this).find('.slides').cycle('pause'); //altered 
    }); 

}); 

但黑背景由自己的CSS造成的:

.slides{ 
    z-index:0; 
    visibility:hidden; 
} 

因此,它是不必要的,有visibility:hidden,如果你想最終刪除它?