出於某種原因,以下不起作用。這是最有可能的我沒有任何睡眠的產品和解決方案可能是非常簡單的...簡單的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