Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How replace and remove table row value by jquery

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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}`
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading