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

jquery刷新獲取隨機(jī)色總結(jié)

original 2019-01-13 00:37:26 216
abstrait:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml&quo

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>jquery獲取隨機(jī)色</title>

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

<style type="text/css">

a{

margin: 50px;

float: left;

width: 100px;

line-height: 100px;

height: 100px;

color: #FFF;

border-radius: 50px;

text-decoration: none;

display: block;

background-color: #00F;

text-align: center;

}


button{

height: 30px;

width: 80px;

margin-top: 160px;

position: relative;

float: left;

margin-left:-450px;

border-radius:10px;

background:blue;

color:white;

}

.bt1{


}

</style>

<script>

function bgc(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(){




/* $('a').mouseover(function(){

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

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

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


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


$(this).css('box-shadow','none')

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

})

*/

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

bgc('a')

var x=100

var y=0

var num = parseInt(Math.random()*(x-y+1)+y)


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

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

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

$('a').html(num)


})



})




</script>

</head>


<body>

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

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

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

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

<button>點(diǎn)擊變色</button>


</body>

</html>



<!--總結(jié)

for()循環(huán)語句


random() 獲取隨機(jī)數(shù)

html()

parseInt()      解析一個(gè)字符串,并返回一個(gè)整數(shù)。

parseFloat() 解析一個(gè)字符串,并返回一個(gè)浮點(diǎn)數(shù)。


-->


Professeur correcteur:天蓬老師Temps de correction:2019-01-13 09:26:47
Résumé du professeur:Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256), 注意在js中, 變量和方法名,是區(qū)分 大小寫的, 寫得不錯(cuò)的

Notes de version

Entrées populaires