abstrak:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>隨機(jī)顏色值</title><script type="text/javascript" src="../zuoye/jq
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>隨機(jī)顏色值</title>
<script type="text/javascript" src="../zuoye/jquery-3.3.1.min.js"></script>
<style>
a{height:300px; width: 300px; border-radius:150px; background: #000;display: inline-block; margin-right:35px; text-decoration:none;}
</style>
<script>
function colo(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(){
colo('a');
$('a').mouseover(function(){
$bg=$(this).css('backgroundColor');
$(this).css('box-shadow','0 0 20px' +$bg);
$(this).css('border-radius','100px');
});
$('a').mouseleave(function(){
$(this).css('border-radius','150px');
})
})
</script>
</head>
<body>
<a href=""></a>
<a href=""></a>
<a href=""></a>
<a href=""></a>
<a href=""></a>
<a href=""></a>
</body>
</html>
Guru membetulkan:天蓬老師Masa pembetulan:2019-03-26 09:38:57
Rumusan guru:獲取隨機(jī)數(shù),js不止一種方法, 想一下,是不是還有其它辦法?