abstrakt://備注:只做到了點(diǎn)擊按鈕改變顏色,在a鏈接中加入數(shù)字并每次點(diǎn)擊數(shù)字都為隨機(jī)值,確實(shí)不會(huì)<!DOCTYPE html><html><head> <title>獲取隨機(jī)數(shù)</title> <script type="text/javascript" src="jquery-3.3.1.min.js&quo
//備注:只做到了點(diǎn)擊按鈕改變顏色,在a鏈接中加入數(shù)字并每次點(diǎn)擊數(shù)字都為隨機(jī)值,確實(shí)不會(huì)
<!DOCTYPE html>
<html>
<head>
<title>獲取隨機(jī)數(shù)</title>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<style type="text/css">
a{
float: left;
display: block;
margin:50px;
width:100px;
height:100px;
line-height:100px;
text-align:center;
color:#fff;
border-radius:50px;
text-decoration:block;
}
.bb{color:red;}
</style>
<script type="text/javascript">
//改變標(biāo)簽的背景顏色
function aa(tag){
var len=document.getElementsByTagName(tag).length
for(var i=0;i<len;i++){
//alert(i)
document.getElementsByTagName(tag)[i].style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+')'
}
}
$(document).ready(function(){
aa('a')
$('button').click(function(){
$('a').toggleClass(function(){
aa('a')
})
})
})
$(document).ready(function(){
//aa('button')
$('a').mouseover(function(){
$bg = $(this).css('backgroundColor')
$(this).css('box-shadow','0px 0px 20px '+$bg)
$(this).css('border-radius',' 20px ')
$(this).click(function(){
$('a').innerHTML.randomNum(10,20)
})
})
$('a').mouseleave(function(){
$(this).css('box-shadow','none')
$(this).css('border-radius',' 50px ')
})
})
</script>
</head>
<body>
<a href="#">1</a>
<a href="#">2</a>
<a href="#">3</a>
<a href="#">4</a>
<br><br><br><br><br><br><br><br><br><br>
<button class="box" style="margin-left:350px">刷新新顏色</button>
</body>
</html>
Korrigierender Lehrer:韋小寶Korrekturzeit:2019-02-25 11:58:29
Zusammenfassung des Lehrers:這個(gè)也就是相當(dāng)于顏色隨機(jī)修改樣式一樣啊 只不過(guò)一個(gè)是修改的樣式中的顏色 還有一個(gè)改的是值啊