Update data in a table with jquery and ajax

后端 未结 5 2061
灰色年华
灰色年华 2020-12-10 22:53

I am trying to update a table according to ajax respond. My update should be insert as the first row inside in my table. With my coding this is ha

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 23:41

    $('#manage_user table > tbody:last').find('tr:first').before(data);
    

    Try this. check my fiddle : http://jsfiddle.net/W4gYY/3/

    If you declared thead then you can use tbody:first and working fine. You do not mention thead that is way html treated as default tbody

    If your html look like below :

    Name Address City Edit Delete
      sdfsdfs dsfs dsfdsf
      aaaaaaa dfsdf dsfsf

    then you can use

    $('#manage_user table > tbody:first').find('tr:first').before(data);
    

    otherwise without thead in html you have to do following code

    $('#manage_user table > tbody:last').find('tr:first').before(data); 
    

提交回复
热议问题