我試圖顯示8個圖像,所有隱藏在頁面加載的CSS除了第一個。當你點擊第一個時,它應該隱藏那個並顯示下一個。等等等等。jQuery點擊圖片顯示下一個
我有這個工作使用fadeIn()
和它設置爲一個計時器,但我想用點擊功能簡單地替換淡入/淡出效果。
我該怎麼做呢?
var journey_img = $('#the_journey_dialog img');
function navigateImages() {
var current = journey_img.filter(".active"), next;
if (current.length == 0 || (next = current.next()).length == 0) {
next = journey_img.slice(0,1);
}
current.removeClass('active').fadeOut(400).promise().done(function(){
next.addClass('active').fadeIn();
});
setTimeout(navigateImages,7*1000);
}
navigateImages();
<div id="the_journey_dialog">
<img src="<?php echo site_url('/'); ?>wp-content/themes/twentytwelve-child/images/1.jpeg" border="0" />
<img src="<?php echo site_url('/'); ?>wp-content/themes/twentytwelve-child/images/2.jpeg" border="0" />
<img src="<?php echo site_url('/'); ?>wp-content/themes/twentytwelve-child/images/3.jpeg" border="0" />
<img src="<?php echo site_url('/'); ?>wp-content/themes/twentytwelve-child/images/4.jpeg" border="0" />
<img src="<?php echo site_url('/'); ?>wp-content/themes/twentytwelve-child/images/5.jpeg" border="0" />
<img src="<?php echo site_url('/'); ?>wp-content/themes/twentytwelve-child/images/6.jpeg" border="0" />
<img src="<?php echo site_url('/'); ?>wp-content/themes/twentytwelve-child/images/7.jpeg" border="0" />
<img src="<?php echo site_url('/'); ?>wp-content/themes/twentytwelve-child/images/8.jpeg" border="0" />
</div>
等等點擊你不想淡入/淡出效果 – 2013-05-01 03:15:31