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

隨機(jī)換顏色jQuery

Original 2018-12-17 13:14:02 249
abstract:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title></title> <style type="text/css"> a{width:100px;height:100px;border-radius:50px;

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

<style type="text/css">


a{width:100px;height:100px;border-radius:50px;background:red;float:left;line-height:100px;margin-left:30px;  text-align: center;text-decoration:none;color: #ccc;}

}

</style>

<script type="text/javascript" src="jq.js"></script>

</head>

<body>

<a href="#">1</a>

<a href="#">2</a>

<a href="#">3</a>

<a href="#">4</a>

</body>

</html>

<script type="text/javascript">

Math.random

Math.floor

function aa(tag) {

var len = document.getElementsByTagName(tag).length

// var a = Math.floor(Math.random()*256)

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)+')'//獲取隨機(jī)顏色

}

}

$(document).ready(function(){

aa('a')

$('a').mousemove(function(){

$bg = $(this).css('backgroundColor')

$(this).css('box-shadow','0px 0px 20px'+$bg)

$(this).css('border-radius','20px')

})

$('a').mouseleave(function(){

$(this).css('border-radius','50px')



})

})

</script>


Correcting teacher:天蓬老師Correction time:2018-12-17 14:06:06
Teacher's summary:這個(gè)作業(yè) , 重點(diǎn)是考察 原生的Math對(duì)象的使用

Release Notes

Popular Entries