功能:文字无缝滚动 (向左+向上)

 

向左滚动:

Jquery代码:

 

<script language="javascript" type="text/javascript">

<!--

function scroll(obj) {

var tmp = (obj.scrollLeft)++;

//当滚动条到达右边顶端时

if (obj.scrollLeft==tmp) obj.innerHTML += obj.innerHTML;

//当滚动条滚动了初始内容的宽度时滚动条回到最左端

if (obj.scrollLeft>=obj.firstChild.offsetWidth) obj.scrollLeft=0;

}

var   t = setInterval("scroll(document.getElementById('scrollobj'))",40);


 $("#scrollobj").mouseover(function(){

clearInterval(t);  

});//鼠标经常时,停止滚动

  $("#scrollobj").mouseout(function(){

setInterval(t = setInterval("scroll(document.getElementById('scrollobj'))",40))

});//鼠标离开时,重新执行函数


//-->

</script>


HTML代码:

 

<DIV id="scrollobj"  style="white-space:nowrap;overflow:hidden;width:500px;"><span>这里是要滚动的内容</span></DIV>


向上滚动:

Jquery代码:

 

<script language="javascript">

var speed=30;

var demo2=document.getElementById("demo2");

var demo1=document.getElementById("demo1");

var demo=document.getElementById("demo");

demo2.innerHTML=demo1.innerHTML;

function Marquee(){

if(demo2.offsetTop-demo.scrollTop<=0){

   demo.scrollTop-=demo1.offsetHeight;

}

else{

   demo.scrollTop++;

}

}

var MyMar=setInterval(Marquee,speed);

demo. {clearInterval(MyMar)};

demo. {MyMar=setInterval(Marquee,speed)};

</script>


 

HTML代码:

 

<div id="demo" style="overflow:hidden;height:168px;width:300px;"> 

<div id="demo1">

   <!--此处放要显示的内容-->

   <p>a</p><p>a</p><p>a</p><p>a</p><p>a</p><p>a</p><p>a</p><p>a</p>

</div>

<div id="demo2"></div>

</div>

 

 

 

-----------------最实际的,还是下载个成功的例子,呵呵!!