1.Jquery
$('input[type=checkbox]:checked').each(function(){
console.log($(this).val());
});
2.JS
function data(){
var obj=document.getElementsByName('test'); //选择所有name="'test'"的对象,返回数组
//取到对象数组后,我们来循环检测它是不是被选中
var s='';
for(var i=0; i<obj.length; i++){
if(obj[i].checked) s+=obj[i].value+','; //如果选中,将value添加到变量s中
}
//那么现在来检测s的值就知道选中的复选框的值了
alert(s==''?'你还没有选择任何内容!':s);
}