js实现跑马灯效果
2017-12-08 本文已影响0人
xin激流勇进

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body{
margin: 0;
}
#i1{
background-color: yellow;
color: red;
margin: 50px auto;
font-size: 60px;
/*width: 350px;*/
text-align: center;
}
#i2{
position: fixed;
width: 100px;height: 30px;
right: 20px;
bottom: 20px;
background-color: #60add5;
}
</style>
</head>
<body>
<div id="i1" onclick="func();">学习前端你最棒</div>
<script>
function func() {
var tag = document.getElementById('i1');
var content = tag.innerText;
var first = content.charAt(0);
var last = content.substring(1, content.length);
tag.innerText = last + first;
}
setInterval('func()', 1000);
</script>
</body>
</html>