现在的位置: 首页 > 综合 > 正文

js实现跑马灯效果

2014年01月12日 ⁄ 综合 ⁄ 共 789字 ⁄ 字号 评论关闭

<script type="text/javascript" >

              function show() {
                var info = document.getElementById('Text1');
                info.value = info.value.substr(1) + info.value[0];//substr(这个参数是起始位置)第二个参数可以不写,取到最后
              }
              setInterval(show, 500);
          
              function show1() {
                  var info1 = document.getElementById('Text2');
                  info1.value = info1.value[info1.value.length-1] + info1.value.substr(0, info1.value.length-1);
              }
              setInterval(show1, 500);

    </script>

    <input id="Text1" type="text" value="欢迎来测试                         " /> <input id="Button1" type="button" value="滚动" onclick="show()"/><br />
        <input id="Text2" type="text" value="                         北京欢迎您" /> <input id="Button2" type="button" value="滚动" onclick="show1()" />

抱歉!评论已关闭.