第一次发表东西,里面都是大神比较多,以后多多学习。

原创 15316186307 随笔 js 284阅读 2017-11-21 00:09:45 举报

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>闪烁的字体</title>
<style>
h1{
width:200px;height:100px;background:#f40;line-height:100px;text-align:center;
}
</style>
</head>
<body>
<h1 id="qq">齐天大圣</h1>
<script>
var oH = document.getElementById("qq");
count = 0;
function fun() {
count++;
if (count == 3) {
count = 1;
}
if (count == 1) {
oH.innerHTML = "孙悟空";
oH.style.background = "yellow";
}
if (count == 2) {
oH.innerHTML = "齐天大圣";
oH.style.background = "#f40";
}
setTimeout(fun, 1000);
}
fun();
</script>
</body>
</html>

评论 ( 4 )
最新评论
18268098842 2017-12-09 16:06:45 4F

多了话 就不要用if else 了 用switch case

15316186307 1F 2017-11-23 19:38:08 3F

好的,谢谢,我试试

x1328457151 2017-11-22 15:47:04 2F

var oH = document.getElementById("qq");
var Bstop=true;
function fun() {
if (Bstop){
oH.innerHTML = "孙悟空";
oH.style.background = "yellow";
Bstop=false;
}else{
oH.innerHTML = "齐天大圣";
oH.style.background = "#f40";
Bstop=true;
}
setTimeout(fun, 1000);
}
fun();

废柴小松 2017-11-21 19:36:37 1F

将 if (count == 2) 用else 替换试试 我也是新手 共同学习吧