日期:2014-05-16 浏览次数:20498 次
1. 选择所有
?
function allChoose() { var checkChoose = $("#allCheckbox"); var all = checkChoose.attr("checked"); if (all) { var ch = $.find("input[type=checkbox]"); $.each(ch,function(){ $(this).attr("checked",true); }); } else { var ch = $.find("input[type=checkbox]"); $.each(ch,function(){ $(this).attr("checked",false); }); } }?
?
?
2. 得出选中后的值
?
function getChooseValue() { var chooseCheckbox = $.find("input[type=checkbox]"); var str = new String(); var length = chooseCheckbox.length; var m = 0; $.each(chooseCheckbox,function(index) { if ($(this).attr("name") == "chooseReport" && $(this).attr("checked")) { if (m != 0) { str = str + ","; } m++; str = str.concat($(this).val()); } }); document.write(str); document.close(); alert(str); }?
?
结果
?
147976,147984,147986,147988,147990,147991?
?