我想顯示覆選框選中項目的值。 這是我的js。在控制檯得到未定義。如何解決這個問題。獲取複選框值並顯示它們
$(document).ready(function() {
$("#checkAll").change(function() {
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
$('#submitButton').click(function() {
var values = $("#add input[name=chkboxName]:checked").map(function() {
row = $(this).closest("tr");
return {
id: $(this).val(),
name: $(row).find("#name").text(),
quantity: $(row).find("#quantity").text()
}
}).get();
$('#result').append(values.name);
console.log(values.name);
});
});
ID必須是唯一的 –