1. select元素
1.1获取select选中的value和text值
<pre name="code" class="html"><select id="select1">
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select>
$("#select1 option:selected").val();
or
$("select1").find("option:selected").val();
$("select1 option:selected").text();
or
$("select1").find("option:selected").text();
1.2.为select设置选中
设置option value为2的项选中
var s='2';
$("#select1").val(s); //IE8 Firefox29有效
设置option text为C的项选中
$("#select1").find("option[text='C']").attr("selected",true); //IE Firefox测试无效
2.checkbox元素
<input type="checkbox" id="chk1"/> 选项
2.1 checkbox检查是否勾选
if($("#chk1").attr("checked")=='checked'){
alert("checked");
}else{
alert("unchecked");
}
2.2 设置checkbox选中
$("#chk1").attr("checked",true);
2.3 设置不选中
$("#chk1").removeAttr("checked");
2.4 设置checkbox不可编辑
<input type="checkbox" id="chk1" disabled = "disabled"/>
or
$("#chk1").attr("disabled","disabled");
去除不可编辑
$("#chk1").removeAttr("disabled");