Question

I'm trying to add a row to a table with jquery. I would like to add the row in first position, but not the very first, I want it to come after the row dedicated to the column headers 'th'. If I try

$('#tableid').prepend() 

obviously the new row comes before the one of 'th's. Any idea of how to do that?

Était-ce utile?

La solution

Assuming your first tr that holds the th you could do:

$('#tableid tr:first').after(newTrContent);

Or you if have them separated out into thead and tbody then you could just do.

$('#tableid tbody').prepend(newTrContent);

Demo

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top