jquery 获取所有选中的多选按钮的值,附:获取未选中的所有多选按钮的值
2016-08-05 14:34
337 查看
html代码
js代码 部分
function ajaxClick(){
var categoryList = "";
$('input:checkbox[name=playaudio]:checked').each(function(i){
if(0==i){
categoryList = $(this).val();
}else{
categoryList += (","+$(this).val());
}
});
alert(categoryList);
}
将选中的依次循环添加到 categoryList中,最终结果是逗号分开的字符串。使用起来也方便些。
获取所有未选中的多选按钮的值
<form class="myform"> <table> <tr> <td style="width: 80px;"> <input type="checkbox" id="category-49" name="playaudio" value="49"> <a style="font-size:18px;">营销</a> </td> <td style="width: 80px;"> <input type="checkbox" id="category-86" name="playaudio" value="86"> <a style="font-size:18px;">投资</a> </td> <td style="width: 80px;"> <input type="checkbox" id="category-50" name="playaudio" value="50"> <a style="font-size:18px;">职场</a> </td> <td style="width: 80px;"> <input type="checkbox" id="category-51" name="playaudio" value="51"> <a style="font-size:18px;">汽车</a> </td> <td style="width: 80px;"> <input type="checkbox" id="category-62" name="playaudio" value="62"> <a style="font-size:18px;">地产</a> </td> </tr> </table> </form> <a href="javascript:;" onclick="ajaxClick(this)" name="" class="btn bgGreen opEditCate ">更新</a>
js代码 部分
function ajaxClick(){
var categoryList = "";
$('input:checkbox[name=playaudio]:checked').each(function(i){
if(0==i){
categoryList = $(this).val();
}else{
categoryList += (","+$(this).val());
}
});
alert(categoryList);
}
将选中的依次循环添加到 categoryList中,最终结果是逗号分开的字符串。使用起来也方便些。
获取所有未选中的多选按钮的值
$("input[name='playaudio']").not("input:checked");
相关文章推荐
- jQuery获取单选按钮radio选中值与去除所有radio选中状态
- jQuery获取单选按钮radio选中值与去除所有radio选中状态的方法
- jquery获取所有选中的checkbox
- jquery获取所有选中的checkbox的ID
- jquery 循环获取checkBox的值,以及对复选框选中,取消,操作按钮
- jquery获取所有选中的checkbox,判断CheckBox是否选中
- jQuery获取单选按钮(Radio)当前选中项的值
- jquery单选按钮循环赋值及获取选中的值
- jquery获取选中单选按钮radio的值,监听type=radio的click事件
- jQuery File Upload 多文件 单击选中或多选文件直接自动上载 无需提交按钮
- JQuery EasyUi Tree获取所有checkbox选中节点的id和内容
- jquery获取所有选中的checkbox
- jquery获取所有选中的checkbox实现代码
- jQuery如何获取选中单选按钮radio的值
- jquery 循环获取checkBox的值,以及对复选框选中,取消,操作按钮
- jquery 单选按钮获取选中的值
- ListView 多选后,获取所有选中项
- jquery中如实现判断复选框是否选中,获取选中单选按钮的值,获取选中复选框的值
- jQuery获取单选按钮(Radio)当前选中项的值
- jquery获取所有选中的checkbox