<div class="codetitle"> <span><a style="CURSOR: pointer" data="13393" class="copybut" id="copybut13393" onclick="doCopy('code13393')"><u>复代码码</u></a></span> 代码如下:</div> <div class="codebody" id="code13393"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 전환//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><html xmlns="http://www.w3.org/1999/xhtml"> <br><머리> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <br><style type="text/css"> <br>본문{<br>글꼴 크기:12px; <br>글꼴 계열:"Courier New", Courier, 고정 폭; <br>글자 간격:5px; <br>} <br>ul{ <br>list-style:none; <br>} <br>li{ <br>너비:130px; <br>높이:130px; <br>줄 높이:130px; <br>세로 정렬:가운데; <br>텍스트 정렬:가운데; <br>플로트:왼쪽; <br>왼쪽 여백:20px; <br>} <br></style> <br><script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <br><title>javascript生成随机颜color</title> <br><script type="text/javascript"> <br>$(function(){ <br>$("ul li").each(function(){ <br>$(this).css("Background-color",getRandomColor()); <br> }); <br>}) <br>function getRandomColor() <br>{ <br>var c = '#'; <br>var cArray = ['0','1','2','3','4','5','6','7','8','9','A' ,'B','C','D','E','F']; <br>for(var i = 0; i { <br>var cIndex = Math.round(Math.random()*15); <br>c = cArray[cIndex]; <br>} <br>c를 반환합니다. <br>} <br><br></script> <br></head> <br><br><본문> <br><div> <br><ul> <br><li>第一个color块</li> <br><li>第two个color块</li> <br><li>第三个color块</li> <br><li>第4个color块</li> <br></ul> <br></div> <br></body> <br></html> <br> </div>