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