Transpose array of TDs into Columns jQuery

后端 未结 2 1235
庸人自扰
庸人自扰 2021-01-23 07:43

Please help me put the cells with a class that corresponds to the column header, in the appropriate column. The iteration should be done per column and then loop through the

2条回答
  •  清酒与你
    2021-01-23 08:01

    Here's how I would go about it. $(this).attr('class') will get the class of the current item in $tempScanner, and $(this).text() will get the contents.

    var $tempScanner = $('table.temp tr td');
    $tempScanner.each(function() {
      // Select the first empty cell in #tblGrid that has the same class as the current 
      // $tempScanner item and give it the same content. Then remove the original table.
      $("table#tblGrid tr td."+$(this).attr('class')+":empty:first").html($(this).text());
    });
    $tempScanner.remove();
    

提交回复
热议问题