Trainings

Sunday, November 22, 2009

get Last tr from a nested table

<html>
<head>
<title>get Last tr from nested table</title>
<script language="javascript" src="jquery-1.3.2.min.js"></script>
<script>
//get the last tr html from a nested table.
function getLastTR()
{
alert($("#tbl tr:last").html());
}
</script>
</head>

<body>
<table id="tbl">
<tr><td>first tr</td></tr>
<tr><td><table><tr><td>II tr</td></tr></table></td></tr>
<tr><td>III tr</td></tr>
</table>
<input type="button" name="bt" value="getLastTR" onclick="getLastTR()" />
</body>
</html>