<!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>
<title></title>
<script src="../Scripts/jquery-1.4.1.js"
type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#getValue").click(function() {
alert($(":radio[name=gender]:checked").val());
});
$("#setValue").click(function() {
$(":radio[name=gender]").val(["保密"]); //给radio设值(选中)时要添加中括号[]
});
});
/*****选中多个*******/
$(function() {
$("#checkBtn").click(function() {
$(":checkbox").val(["羽毛球",
"篮球"]);
});
});
</script>
</head>
<body>
<input type="radio" value="男"
name="gender" />男<br />
<input type="radio" value="女"
name="gender" />女<br />
<input type="radio" value="保密"
name="gender" />保密<br />
<input type="button" value="取值"
id="getValue" />
<input type="button" value="设置" id="setValue"
/>
<br />
<br />
<br />
<input type="checkbox" value ="篮球" />篮球
<input type="checkbox" value
="足球"/>足球
<input type="checkbox" value ="乒乓球"/>乒乓球
<input
type="checkbox" value ="冰球"/>冰球
<input type="checkbox" value
="羽毛球"/>羽毛球
<input type="checkbox" value
="橄榄球"/>橄榄球
<input type ="button" id ="checkBtn" value ="选中多个"
/>
</body>
</html>
JQ 操作样式,单选按钮跟复选框,布布扣,bubuko.com