JS实现跑马灯效果

来源:互联网 发布:福州java兼职 编辑:程序博客网 时间:2024/06/06 09:01

跑马灯效果 即可以用js实现,也可以用html的marquee元素实现。


<!-- 公告跑马灯效果  --> <div class="notice-show">  <div></div> </div>$(document).ready(function(){ noticeScroll();});//一个函数,循环调用  function noticeScroll(){  var noticeContent = $(".notice-show div").text(); if(noticeContent.length > 0){ //取出要显示文字的第一个字符然后拼接到字符串的末尾    noticeContent= noticeContent.substr(1) + noticeContent.substr(0,1);    $(".notice-show div").text(noticeContent);//每隔半秒调用一次,可以更改数字使它更快或更慢  setTimeout(noticeScroll,500); //setTimeout("noticeScroll()",500);    // setInterval(noticeScroll, 500); //每隔0.5秒就动一次;  }} 




0 0