您的位置:首页 > Web前端 > JavaScript

js实现跑马灯效果

2013-05-07 19:38 417 查看
<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()" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: