Pregunta

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?

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top