Reputation: 20571
I'm trying to grow a table upward from a fixed position, so that if for example the first table row is at 100px, the next one would be at 110px (grows upward instead of the default downward). How could I achieve this effect if I am dynamically adding table rows?
Upvotes: 2
Views: 222
Reputation: 3175
If I understand correctly and you are wanting to insert new rows into the table, but above the existing rows as opposed to below. This would be a prepend
as opposed to an append
, and you have a couple of nice jQuery
options to do this:
$('<tr><td>Stuff</td></tr>').insertBefore('table > tbody > tr:first');
$('table > tbody > tr:first').before('<tr><td>Stuff</td></tr>');
$("<tr><td>prependTo</td></tr>").prependTo("table > tbody");
Upvotes: 0
Reputation: 7165
Use absolute positioning and instead of setting the offset with top use bottom. With this property you can ensure the position of the bottom edge of your div - any change in size will force the div to expand upwards.
Upvotes: 2