views:

28

answers:

1

i have a table like

<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 ' i send ajax request & after successful response i remove the respective TR using $('#id_of_tr').remove();.

till here everything goes fine but now i want to update Sr. No.s of each row. Because Initially order is 1 2 3 , when i remove second row then it becames 1 3 which i want to update it to 1 2.

I hope this would help.

A: 

Like this:

// Your AJAX Call
$.post('/delete', {id: 2}, function(data){
  // your code that removes the tr here

  $('table tr').each(function(index, el){
    $(this).find('td:first').text(index + 1);
  })
})
Doug Neiner
thanks a lot. This one really helped me.But again I stucked in new problem. Let me come out of that.Once again thanks.