首页 > 其他 > 详细

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

时间:2019-11-04 18:17:05      阅读:258      评论:0      收藏:0      [点我收藏+]

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

 

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

原文:https://www.cnblogs.com/xzp0222/p/11793405.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!