loop through all td elements in a table

前端 未结 3 1709
执笔经年
执笔经年 2021-01-04 00:32

How would I loop through all the td elements in a table? I need to find the id of each td and compare it against a value. Any help would really be appreciated!

3条回答
  •  离开以前
    2021-01-04 01:29

    $('#tableId').find('tr').each(function () {
     $(this).find("td[id^='tdId']").each(function (i, item) {
          //do your task here
            });
     });
    

    Or the effective one is get all the tds from table first

    var totalTdsInTable = $("#table-id td");
    

    Now loop through totalTdsInTable

提交回复
热议问题