Home > other >  How can add database table ID into table row as class or ID
How can add database table ID into table row as class or ID

Time:09-22

I want to add database table ID to table row as a class or ID.

$.each(response.sellorderbookdata, function(key, item) {
  if (item.total !== 0) {
    $("tr").addClass(item.id);
    $('tbody.sellbook').append('<tr>\
     <td >'   item.price   '</td>\
     <td >'   item.amount   '</td>\
     <td >'   item.total   '</td>\
     </tr>');
  }
});
}

Will it work? The data inside table rows are dynamically pulled from a database. It needs to update whenever data is retrieved and I want to replace some text value in the table cell by mention table row.

How can I make it work?

CodePudding user response:

Use string concatenation rather than jquery

$.each(response.sellorderbookdata, function(key, item) {
  if (item.total !== 0) {
    $('tbody.sellbook').append('<tr >'\
     <td >'   item.price   '</td>\
     <td >'   item.amount   '</td>\
     <td >'   item.total   '</td>\
     </tr>');
  }
});
}
  • Related