以下代碼jquery實(shí)現(xiàn)簡單的滾動(dòng),原理是克隆第一個(gè)li然后放到末尾,接著讓它往上滑動(dòng)然后清除掉,反復(fù)循環(huán)
<script type="text/javascript">
function slide(ClassName){
var ID = setInterval ("run('"+ClassName+"')",1000);
$('.'+ClassName).mouseover(function(){
clearInterval(ID)
}).mouseout(function(){
ID = setInterval ("run('"+ClassName+"')",1000);
});
}
function run(ClassName){
$('.'+ClassName).find('li').first().clone().appendTo('.'+ClassName);
$('.'+ClassName).find('li').first().slideUp("slow",
function(){
$('.'+ClassName).find('li').first().remove();
}
);
}
$(function(){
slide('side-news-cnt');
});
</script>