Iterating through table cells using jquery

前端 未结 2 801
长发绾君心
长发绾君心 2021-02-13 20:25

I have a table containing a variable number of columns. I wrote a function to iterate through each cell in each row to do the following:

  1. Check for the presence of
2条回答
  •  轮回少年
    2021-02-13 21:15

    When you select td pass the context as tr(this) so that it will look for td only in the current tr. Try this.

    $("#MarketsTable tr").each(function () {
    
        $('td', this).each(function () {
            var value = $(this).find(":input").val();
            var values = 100 - value + ', ' + value;
    
            if (value > 0) {
                $(this).append(htmlPre + values + htmlPost);
            }
         })
    
    })
    

提交回复
热议问题