hello friend i have table as follow
<tbody class="sellbook">
<tr class="foobar-26">
<td>price</td>
<td>amount</td>
<td>total</td>
</tr>
<tr class="foobar-27">
<td>price</td>
<td>amount</td>
<td>total</td>
</tr>
<tr class="foobar-28">
<td>price</td>
<td>amount</td>
<td>total</td>
</tr>
</tbody>
i need to update data in table row by mention its table row class name and need to remove also,
condition is as folow
if value is zero , remove table row foo25 , else replace with new
var newtr = '<td>'+e.message.price+'</td>'+
'<td>'+e.message.amount+'</td>'+
'<td>'+e.message.total+'</td>';
let trclass = "foobar-"+e.message.id+"";
if(e.message.amount==0) {
$('.trclass').remove();
}else{
$('.trclass').html(newtr);
}
but nothing happen with this code , what wrong in code .
can someone help me.
>Solution :
This isn’t how you use a variable in a string:
'.trclass'
That’s just a literal string. You can concatenate your value to a string:
'.' + trclass
or use the value in a template literal:
`.${trclass}`