jquery获取select和checkbox的值很简单,但是每次都忘了,在此记录一笔
<input type="checkbox" name="box">1
<input type="checkbox" name="box">2
<input type="checkbox" name="box">3
<input type="checkbox" name="box">4
获取选定的值 var $boxs = $("input[name='box']:checked");
可以将多选的值存贮在array中
var arr = new Array();
var $boxs = $("input[name='box']:checked");
$boxs.each(function(){
arr.push($(this).val());
});
jquery 获取select的选定值
<select id = "select">
<option>1</option>
<option>2</option>
</select>
直接使用 $("#select").val()即可获得选定的值