出于某种原因,以下不起作用。这是最有可能的我没有任何睡眠的产品和解决方案可能是非常简单的...简单的JQuery定时图像旋转
JS:
<script src="http://code.jquery.com/jquery-1.6.1.js"> </script>
<script>
function swapImages(){
var $active = $('#switch .active');
var $next = ($('#switch .active').next().length > 0) ? $('#switch .active').next() : $('#switch img:first');
$active.fadeOut(function(){
$active.removeClass('active');
$next.fadeIn().addClass('active');
});
}
$(document).ready(function(){
// Run our swapImages() function every 5secs
setInterval('swapImages()', 5000);
}
</script>
HTML:
<div id="switch"><img src="images/chalk.jpg" class="active" /><img src="images/students.jpg" /></div>
CSS:
#switch{
margin-left: auto;
margin-right: auto;
width: 996px;
height: 374px;
}
#switch img{
display:none;
}
#switch img.active{
display:block;
}
好找!不错的插件,但是,它不像我写的那么轻......我所有的东西都是我需要的,所以我希望尽可能让它工作。我只是难住为什么这不起作用。 – coderego 2011-05-30 14:36:56