<input type="checkbox" name="item" value="apple"/>apple <input type="checkbox" name="item" value="orange"/>orange <input type="checkbox" name="item" value="kiwifruit"/>kiwifruit <input type="checkbox" name="item" value="banana"/>banana <input type="checkbox" name="all" value=""/>all //获取选中的item,所有 type="checkbox" 的 <input> 元素 $(':checkbox').each(function(){ console.log($(this).val()); }); //获取选中的item,所有被选中的 input 元素 $(':checked').each(function(){ console.log($(this).val()); }); //获取选中的item,指定name、类型的Input元素 $('input:checkbox[name="item"]:checked').each(function(){ console.log($(this).val()); }); //点击全选触发 $('input:checkbox[name="all"]').on('click', function(){ $('input:checkbox[name="item"]').attr('checked', this.checked); });