jQuery实现变色

<title></title>

<script src="jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
function backgorundColor(i) {
// this.document.body.style.backgroundColor = i;
// this.document.getElementById('div1').style.backgroundColor= i;
this.document.getElementsByName('div').item[0].style.backgroundColor = i;
}

function changeColor() {
var a = document.getElementsByName('color');
for (var i = 0; i < a.length; i++) {
if (allradio[i].checked == true) {
document.body.style.backgroundColor = a[i].value;
}
}
}

// $(function () {
// $('input').click(function () {
// $('body').css('background-color',$(this).attr('value'));
// })
// })
</script>
</head>
<body>
<div id="div1" style="width:200px;height:200px;"></div>

<input id="Radio1" type="radio" value="Red" name="color" onclick="backgorundColor('Red')" /> 红色
<input id="Radio2" type="radio" value="Blue" name="color" onclick="backgorundColor('Blue')" />蓝色
<input id="Radio3" type="radio" value="Green" name="color" onclick="backgorundColor('Green')" />绿色
<input id="Radio4" type="radio" value="Orange" name="color" onclick="backgorundColor('Orange')" />橙色
</body>

posted @ 2013-04-22 21:41  奇奇博客  阅读(346)  评论(0编辑  收藏  举报