摘要:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">&
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>随机抽取颜色</title>
<script type="text/javascript" src="jquery-3.3.1.min.js">
</script>
<script type="text/javascript">
function aa(tag){
var len=document.getElementsByTagName(tag).length
for(var i=0;i<len;i++){
document.getElementsByTagName(tag)[i].style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+')'
}
}
function cc(tag){
var len=document.getElementsByTagName(tag).length
for(var i=0;i<len;i++){
document.getElementsByTagName(tag)[i].text=Math.floor(Math.random()*256)
}
}
$(document).ready(function(){
aa('a')
$('button').click(function(){
aa('a')
cc('a')
$('a').mouseover(function(){
$bb=$(this).css('backgroundColor')
$(this).css('box-shadow','0px 0px 40px '+$bb)
$(this).css('border-radius','20px')
})
$('a').mouseleave(function(){
$bb=$(this).css('backgroundColor')
$(this).css('box-shadow','none')
$(this).css('border-radius','100px')
})
})
})
</script>
<style>
a{
display:block;
background-color: aliceblue;
width: 200px;
height: 200px;
border-radius: 100px;
line-height: 200px;
text-align: center;
float:left;
text-decoration: none;
margin:50px 20px;
}
</style>
</head>
<body>
<button>点击换色</button>
<a href="#">1</a>
<a href="#">2</a>
<a href="#">3</a>
<a href="#">4</a>
</body>
</html>
批改老师:查无此人批改时间:2019-02-11 09:42:30
老师总结:作业完成的不错,下次把代码整理下。先看下math.random这个函数做什么的,就 知道为啥*256了。也可以私聊讲课老师,作业区无法互动的。