亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

完成jQuery隨機(jī)背景顏色動(dòng)畫案例

Original 2018-12-09 01:33:52 272
abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <script type="text/javascript" src="jqu
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="jquery-3.3.1.js"></script>
<style type="text/css">
a{ color: red;
width: 100px;
height: 100px;
display: block;
background-color: #ccc;
float: left;
margin-left: 30px;
line-height: 100px;
text-align: center;
text-decoration: none;
border-radius: 50px;
}
</style>
<script type="text/javascript">
function change(tag) {
var leng=document.getElementsByTagName(tag).length;
for(var i=0;i<leng;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(){
change('a');
$('a').mouseover(function(){
$bg = $(this).css('backgroundColor');
$(this).css("box-shadow","0px 0px 20px "+$bg);
$(this).css("border-radius","20px");
})

$('a').mouseleave(function(){
$bg = $(this).css('backgroundColor');
$(this).css("box-shadow","none");
$(this).css("border-radius","50px");
})
})

</script>
</head>
<body>
<a href="#">a</a>
<a href="#">b</a>
<a href="#">c</a>
<a href="#">d</a>
</body>
</html>

20181209012954.png

經(jīng)過本案例學(xué)習(xí)發(fā)現(xiàn)dom的功能好強(qiáng)大,課外還需要多多練習(xí)讓dom里的功能運(yùn)用到得心應(yīng)手。

Correcting teacher:韋小寶Correction time:2018-12-09 09:11:15
Teacher's summary:寫的很不錯(cuò)!總得一個(gè)說是jquery很強(qiáng)大!哦不對(duì),應(yīng)該是js很強(qiáng)大!課后多多了解jquery,你會(huì)發(fā)現(xiàn)更牛X的東西哦!

Release Notes

Popular Entries