<!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>by 阿会楠-给我一双翅膀,我也将展翅高飞</title>
<script>
window.οnlοad=function(){
var putColors = document.getElementById("myDiv").getElementsByTagName("input");
for(var i=0;i<putColors.length;i++){
putColors[i].οnclick=function(){
document.body.style.backgroundColor=this.value;
}
}
}
</script>
</head>
<body>
<div id="myDiv">
<input name="putColor" type="radio" value="red" />红色
<input name="putColor" type="radio" value="green" />绿色
<input name="putColor" type="radio" value="blue" />蓝色
</div>
</body>
</html>
转载于:https://blog.51cto.com/liaoshiyong/1220482