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

刷新隨機(jī)顏色小案例

オリジナル 2019-01-21 11:39:42 186
サマリー:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>獲取隨機(jī)顏色</title> <script type="text/javascript" src="jq
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>獲取隨機(jī)顏色</title>
	<script type="text/javascript" src="jquery-3.3.1.js"></script>
	<style type="text/css">
		a{
			width: 100px;
			height: 100px;
			display: block;
			float: left;
			margin: 20px;
			border-radius: 50px;
			line-height:100px;
			text-align: center;
			text-decoration:none;
		}
		.clear{clear: both}
	</style>
	<script type="text/javascript">
		function aa(tag1) {
			var len=document.getElementsByTagName(tag1).length
			for(var i=0;i<len;i++){
				//Math:數(shù)學(xué)函數(shù)對(duì)象   floor 作用:四舍五入     random:隨機(jī)  作用:獲取隨機(jī)值
				document.getElementsByTagName(tag1)[i].style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+')'
				document.getElementById('num').innerHTML=Math.floor(Math.random()*1000)
		    }
	    }
		$(document).ready(function(){
			$('button').click(function(){
				aa('a')
				
			})
		})
	</script>
</head>
<body>
	<a href="" id="num"></a>
	<a href="" id="num"></a>
	<a href="" id="num"></a>
	<a href="" id="num"></a>
    <div class="clear"></div>
	<button>刷新</button>
</body>	
</html>

為什么只有第一個(gè)a標(biāo)簽添加了隨機(jī)數(shù),不懂怎么解決

添削の先生:韋小寶添削時(shí)間:2019-01-21 11:59:39
先生のまとめ:其他的標(biāo)簽頁(yè)可以加啊 你把id才能class id是唯一的啊 你要使用class接著再換一下class選擇器就可以了啊

手記を発表する

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