随机颜色变化
<!DOCTYPE>
<html>
<head>
<title>Document</title>
<meta charset="utf-8">
</head>
<body>
<p>我会变奥!</p>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$(function(){
/*
$("p").click(function(){
$(this).css("color",randomColor());//鼠标点击的时候字体颜色会随机改变
});
*/
$("p").css("color",randomColor());//加载页面的时候字体颜色会随机改变
function randomColor(){
var r = Math.floor(Math.random() * 256);
var g = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
return "rgb("+r+","+g+","+b+")";
}
});
</script>
</body>
</html>