Forum Moderators: open

Message Too Old, No Replies

JQuery - Append to beginning of table

         

realestatesteve

6:38 pm on Dec 30, 2008 (gmt 0)

10+ Year Member



Hi everyone!
I've successfully learned how to do an ajax call to add form contents to my database, and also how to load the last entry submitted back onto the page in a table.

I'm currently using this method:


$.ajax({
url: 'load_last_comment.php',
cache: false,
success: function(result){
$('#all_comments').append(result);
}
});

My question is: How do I append the result to the BEGINNING of the table, instead of the end? The #all_comments is an ID reference for the table all comments are displayed in.

Thanks in advance!

realestatesteve

6:44 pm on Dec 30, 2008 (gmt 0)

10+ Year Member



><! Prepend! I just need to make sure I have it prepend after the initial <thead>. Hrm.

realestatesteve

6:47 pm on Dec 30, 2008 (gmt 0)

10+ Year Member



Got it! (sorry for thinking out loud to myself here, heh)


success: function(result){
$('#all_comments').find('thead').append(result);

bedlam

11:19 pm on Dec 30, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This:

$('#all_comments').find('thead').append(result);

...should also work equally well this way:

$('#all_comments thead').append(result);

-- b