我正在尝试显示 8 个图像,除了第一个之外,所有图像都隐藏在 css 的页面加载中。当您单击第一个时,它应该隐藏那个并显示下一个。等等等等。
我已经使用fadeIn()
and进行了这项工作,fadeOut()
并将其设置为计时器,但我想简单地用单击功能替换淡入/淡出效果。
我该怎么做呢?
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>