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

js加jq實(shí)現(xiàn)隨機(jī)顏色

オリジナル 2019-01-24 15:36:08 280
サマリー:<!DOCTYPE html><html><head><meta charset="utf-8" /><title>Page Title</title><script src="https://code.jquery.com/jquery-3.1.1.min.js"><

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

<title>Page Title</title>

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

</head>

<style>

a{

float:left;

display:block;

margin:50px;

width:100px;

line-height:100px;

text-align: center;

height: 100px;

color: #fff;

border-radius: 50px;

text-decoration: none;

}

</style>

<body>

<a href=""></a>

<a href=""></a>

<a href=""></a>

<a href=""></a>

</body>

</html>

<script>

//改變標(biāo)簽背景色的函數(shù)

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

changecolor('a');

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

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

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

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

})

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

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

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

})

})

</script>

//Math.random獲取的是一個(gè)0到1的隨機(jī)值


添削の先生:天蓬老師添削時(shí)間:2019-01-24 17:26:02
先生のまとめ:Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256) Math是js內(nèi)置的重要對(duì)象之一, 可以實(shí)現(xiàn)很多事情,特別是一些動(dòng)畫效果,必須用到,多多練習(xí)

手記を発表する

人気のある見出し語(yǔ)