The example in this article shares with you the marquee effect code implemented in javascript, which implements functions such as news announcements. The following is a marquee example for your reference. I hope it can be helpful to friends in need.
Operation rendering:
The code example is as follows:
<!DOCTYPE html> <html> <head> <meta charset="gb2312"> <title>javascript新闻跑马灯效果</title> </head> <script type="text/javascript"> var msg="脚本之家欢迎您http://www.jb51.net"; var interval = 100; var space10=""; var seq=0; function Scroll() { document.tmForm.tmText.value = msg.substring(seq, msg.length) + space10 + msg.substring(0, msg.length); seq++; seq++; if(seq >msg.length) { seq=0 } window.setTimeout("Scroll();", interval ) } </script> <body onload="Scroll();" > <center> <form name="tmForm"> <input type="text" name="tmText" size="45"> </form> </center> </body> </body> </html>
I hope this article will be helpful to everyone in learning javascript programming.