abstract:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">&
<!DOCTYPE html>
<html lang="en">
<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>
<link rel="stylesheet" href="css/php.css" type="text/css">
<script src="js/jquery-3.3.1.js"></script>
<script src="js/php.js" type="text/javascript"></script>
<style>
/* random */
.random{width: 1200px;margin: 0 auto;background: #ccc;margin-top: 40px;}
.random ul li{width: 100px;height: 100px;color: #000;border-radius: 50%;float: left;margin-right: 10px;line-height: 100px;
text-align: center;}
</style>
<script>
$(function(){
function ran(tag){
var tag1 = document.getElementsByTagName(tag).length;
for(var i=0;i<tag1;i++){
document.getElementsByTagName(tag)[i].style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+
Math.floor(Math.random()*256)+')'
}
}
ran('li');
$('.random ul li').mouseover(function(){
var backg = $(this).css('backgroundColor');
$(this).css('background','backg');
$(this).css({'boxShadow':'0px 0px 20px #ccc','borderRadius':'10px'});
})
$('.random ul li').mouseleave(function(){
var backg = $(this).css('backgroundColor');
$(this).css({'borderRadius':'50%','backgroundColor':'backg','boxShadow':'none'})
})
})
</script>
</head>
<body>
<div class="random">
<ul>
<li>php</li>
<li>php</li>
<li>php</li>
<li>php</li>
<li>php</li>
</ul>
</div>
</body>
</html>
Correcting teacher:灭绝师太Correction time:2018-11-19 16:17:10
Teacher's summary:哎呀,你这个代码颜色真好看……测试了效果不错 继续加油啊!