以下代碼jquery實現(xiàn)簡單的滾動,原理是克隆第一個li然后放到末尾,接著讓它往上滑動然后清除掉,反復(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>