<div class="span1">
<label class="radio">
<input class="man" type="radio" name="sex" value="男" checked="checked" />
男
</label>
<label class="radio">
<input type="radio" name="sex" value="女" />
女
</label>
</div>
radio: 获取
var sex = $(":radio[name=sex]:checked").val();
var sex =$("input[name=sex]:checked").val();
设置
$(".man").attr("checked", true);
<div class="checkbox span1">
<label>
<input type="checkbox" class="poor" />
贫困户
</label>
</div>
checkbox: 获取
var poor=$(".poor").is(':checked');//单个
设置:$(".poor").attr("checked", true);
<div class="input-prepend">
<span class="add-on">教育程度</span>
<select class="input-small education">
<option>小学</option>
<option>初中</option>
<option>高中</option>
<option>大学</option>
<option>研究生</option>
<option>博士</option>
</select>
</div>
select: 获取
var education = $(".education").find("option:selected").val();
设置:
if ($(".education").get(0).options[0].value == a[12]) {
$('.education').attr('value', '小学');
}
else if ($(".education").get(0).options[1].value == a[12]) {
$('.education').attr('value', '初中'); //设置值为"初中"的option为选中状态
}
else if ($(".education").get(0).options[2].value == a[12]) {
$('.education').attr('value', '高中'); //设置值为"高中"的option为选中状态
}
else if ($(".education").get(0).options[3].value == a[12]) {
$('.education').attr('value', '大学'); //设置值为"大学"的option为选中状态
}
else if ($(".education").get(0).options[4].value == a[12]) {
$('.education').attr('value', '研究生'); //设置值为"研究生"的option为选中状态
}
else if ($(".education").get(0).options[5].value == a[12]) {
$('.education').attr('value', '博士'); //设置值为"博士"的option为选中状态
}