通过点击选中的checkbox获取该行td的值
并将对象封装,返回JSON对象
// 弹出层保存事件 function addMarketClues () { var marketCluesList = []; // table 中checkbox获取选中行的所有列的数据 var check = $("table input[type=checkbox]:checked");//在table中找input下类型为checkbox属性为选中状态的数据 check.each(function () { var marketClues = {}; var row = $(this).parent("td").parent("tr");//获取选中行 marketClues.studentName = row.find("[name='repeatStudentName']").html(); //获取td中name='repeatStudentName'的值 marketClues.tel = row.find("[name='repeatTel']").html(); marketClues.grade = row.find("[name='repeatGrade']").html(); marketClues.age = row.find("[name='repeatAge']").html(); marketClues.school = row.find("[name='repeatSchool']").html(); marketClues.entryName = row.find("[name='repeatEntryName']").html(); marketClues.intentionCampus = row.find("[name='repeatIntentionCampus']").html(); marketCluesList.push(marketClues) }); console.log(JSON.stringify(marketCluesList)); }
获取选中的checkbox的值
//获取选中的checkbox的值 var ids = []; $("input[name='ids']:checked").each(function(i){ ids.push($(this).val()) $("body").append("<p>"+$(this).val()+"</p>") })