码迷,mamicode.com
首页 > 其他好文 > 详细

跑马灯

时间:2016-03-31 01:42:12      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>练习</title>
    <script type="text/javascript">
        onload = function () {
            var txt = document.getElementById("txt");
            var txt2 = txt.innerHTML.trim();
            // alert(txt.innerHTML.trim().charAt(0));
            //alert(txt.innerHTML.trim().substr(0,2));

            var paoMaDeng = function () {
        //两个获取字符的方法,charAt(0)和substr(0,1)
var first = txt2.charAt(0); var rest = txt2.substr(1); txt2 = rest + first; txt.innerHTML = txt2; } aaa = setInterval(paoMaDeng, 100); } </script> </head> <body> <p id="txt"> 北京欢迎你!</p> <input type = "button" value = "停止" id = "btn" onclick="clearInterval(aaa);"/> </body> </html>

 

跑马灯

标签:

原文地址:http://www.cnblogs.com/Jacklovely/p/5339474.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!