我是Jquery的新手。我有这种复选框数组
<input type="checkbox" name="propertyfeatures[Appliances]" value="Dishwasher">
<input type="checkbox" name="propertyfeatures[Appliances]" value="Dryer" >
<input type="checkbox" name="propertyfeatures[Appliances]" value="Freezer">
<input type="checkbox" name="propertyfeatures[Appliances]" value="Garbage disposal" >
<input type="checkbox" name="propertyfeatures[Appliances]" value="Microwave">
<input type="checkbox" name="propertyfeatures[Appliances]" value="Range / Oven" >
<input type="checkbox" name="propertyfeatures[Appliances]" value="Refrigerator">
<input type="checkbox" name="propertyfeatures[Appliances]" value="Trash compactor" >
<input type="checkbox" name="propertyfeatures[Appliances]" value="Washer">
<input type="checkbox" name="propertyfeatures[Appliances]" value="None" >
如果选中“无复选框”,我将如何在jquery中获取所有Appliances数组值
答案 0 :(得分:0)
的jsfiddle:
将None
复选框设为ID
,例如save_value
:
<input type="checkbox" name="propertyfeatures[Appliances]" value="None" id="save_value">
$(function(){
$('#save_value').click(function(){
var val = [];
$(':checkbox:checked').each(function(i){
val[i] = $(this).val();
alert(val[i]);
});
});
});