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

獲取隨機(jī)顏色刷新給新色并產(chǎn)生隨機(jī)數(shù)

asal 2019-02-09 14:58:51 225
abstrak:代碼這東西很嚴(yán)謹(jǐn),練習(xí)過(guò)程中就因?yàn)橐?hào)前沒(méi)打空格郁悶了半天沒(méi)找到問(wèn)題。接著又是撤銷的時(shí)候總認(rèn)為刪掉哪行代碼就可以,又掉坑里了。好多坑呀。。。知識(shí)點(diǎn):靈活運(yùn)用所學(xué)到的知識(shí)。parseInt()將字符串轉(zhuǎn)換為整數(shù)類型,忽略非數(shù)字類型click () 點(diǎn)擊事件 mouseover() 鼠標(biāo)移上事件mouseleave()鼠標(biāo)離開(kāi)事件+ 拼接字符串新知識(shí)點(diǎn):Math.random()返回介于 0 ~ 1

代碼這東西很嚴(yán)謹(jǐn),練習(xí)過(guò)程中就因?yàn)橐?hào)前沒(méi)打空格郁悶了半天沒(méi)找到問(wèn)題。接著又是撤銷的時(shí)候總認(rèn)為刪掉哪行代碼就可以,又掉坑里了。好多坑呀。。。

知識(shí)點(diǎn):靈活運(yùn)用所學(xué)到的知識(shí)。

parseInt()將字符串轉(zhuǎn)換為整數(shù)類型,忽略非數(shù)字類型

click () 點(diǎn)擊事件 mouseover() 鼠標(biāo)移上事件mouseleave()鼠標(biāo)離開(kāi)事件

+ 拼接字符串

新知識(shí)點(diǎn):Math.random()返回介于 0 ~ 1 之間的一個(gè)隨機(jī)數(shù)。

<!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>獲取隨機(jī)色</title>

<script type="text/javascript" src="jquery/jquery-3.3.1.js"></script>

<style>

a{

float: left;

display: block;

margin: 50px;

width: 100px;

line-height: 100px;

color: rgb(243, 235, 235);

border-radius: 50px;

text-align: center;

text-decoration: none;

/* background: #ccc; */

}

</style>

</head>

<body>

<script type="text/javascript">

function aa(tag) {

var len=document.getElementsByTagName(tag).length

for (let 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(){

aa('a')

$('button').click(function(){

$b=parseInt(Math.random()*10)

aa('a')

$('a').text($b)

})

$('a').mousemove(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 ')

})

})

/* $(document).ready(function(){

       aa('a')

   }) */

</script>

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

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

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

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

<button>刷新</button>

</body>

</html>




Guru membetulkan:查無(wú)此人Masa pembetulan:2019-02-11 09:33:13
Rumusan guru:作業(yè)完成的不錯(cuò)??又饕悄氵€不熟悉,熟悉的話,就不會(huì)有常規(guī)錯(cuò)誤了。繼續(xù)加油。

Nota Keluaran

Penyertaan Popular