js实现跑马灯效果
作者:
xin激流勇进 | 来源:发表于
2017-12-08 19:20 被阅读0次
image.png
<!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>
本文标题:js实现跑马灯效果
本文链接:https://www.haomeiwen.com/subject/wzkyixtx.html
网友评论