table 中checkbox获取选中行的所有列的数据


通过点击选中的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>")
  })

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM