I am facing a challenge with a web page where I have a table nested inside of a TD tag. Despite the unconventional approach, I need to ensure that the height of the nested table matches the height of the TD cell containing it upon page load. Currently, I achieve this using the following code:
$(document).ready(function()
{
$('.TakeOffItemGroupTable').each(function()
{
$(this).height($(this).closest('td').height());
});
}
Although this method works, resizing multiple tables on the page can significantly slow down performance in IE8 (compared to Chrome and Firefox). This is because
$(this).height($(this).closest('td').height());
takes:
- 1ms in Chrome
- 18ms in Firefox
- 330ms in IE8
Therefore, I am seeking an alternative approach to automatically adjust the nested table’s height based on its container's height.
Some methods I have attempted include:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<table border="1" >
<tr>
<td width="100px">JKLSD FASJDFKLSA DFKLADFJL KASDJFKLSAD JFSAKLDF</td>
<td style="height: 100%;">
<table style="height:100%;" border="1">
<tr>
<td>
I should be 100% tall!
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
While this solution works in Firefox, it does not render properly in IE.