获取随机色外加按钮刷新和点击次数更迭

Original 2019-02-19 23:29:08 326
abstract:获取随机色外加按钮刷新和点击次数更迭<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title></title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jqu

获取随机色外加按钮刷新和点击次数更迭

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>

<style type="text/css">

a {

display: block;

width: 100px;

height: 100px;

border-radius: 50px;

text-align: center; 

line-height: 100px;

float: left;

text-decoration: none;

color: white;

margin-left: 20px;

}

</style>

<script type="text/javascript">

function abc(tag) {

var a = document.getElementsByTagName(tag).length;

for (var i = 0; i < a; i++) {

document.getElementsByTagName(tag)[i].style.backgroundColor = 'rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()* 256)+','+Math.floor(Math.random() * 256)+')'

num[i]=0

}

}

function aa(tag) {

var a = document.getElementsByTagName('a').length;

tag.innerHTML=parseInt(tag.innerHTML)+1

tag.style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()* 256)+','+Math.floor(Math.random() * 256)+')'

}

$(document).ready(function() {

abc('a')

})

</script>

</head>

<body>

<a href="#" onclick="aa(this)">0</a>

<a href="#" onclick="aa(this)">0</a>

<a href="#" onclick="aa(this)">0</a>

<a href="#" onclick="aa(this)">0</a>

</body>

</html>

Correcting teacher:查无此人Correction time:2019-02-20 09:07:05
Teacher's summary:完成的不错。下次把代码缩进,看着整齐。js语句每行后面增加 ;号,继续加油。

Release Notes

Popular Entries