javascript - how to update Sr. No. COLUMN after removing a TR from TABLE -


i have table

<table> <tr>     <td>sr. no.</td>     <td> name</td>      <td>$nbsp;</td> </tr> <tr>     <td>1</td>     <td>abc</td>     <td>remove button</td>  </tr> <tr>     <td>2</td>     <td>xyz</td>     <td>remove button</td> </tr> <tr>     <td>3</td>     <td>def</td>     <td>remove button</td> </tr> 

onclick of ' remove button ' send ajax request & after successful response remove respective tr using $('#id_of_tr').remove();.

till here goes fine want update sr. no.s of each row. because order 1 2 3 , when remove second row becames 1 3 want update 1 2.

i hope help.

like this:

// ajax call $.post('/delete', {id: 2}, function(data){   // code removes tr here    $('table tr').each(function(index, el){     $(this).find('td:first').text(index + 1);   }) }) 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -