Created
August 2, 2012 15:17
-
-
Save rootbear/3237849 to your computer and use it in GitHub Desktop.
Javascript: Remove Last Row from Table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>remove last row from a table</title> | |
<script language="JavaScript" type="text/javascript"> | |
<!-- | |
var rws; | |
function RemoveRow(obj){ | |
obj=document.getElementById(obj); | |
rws=obj.getElementsByTagName('TR'); | |
obj.removeChild(rws[rws.length-1]); | |
} | |
//--> | |
</script> | |
</head> | |
<body> | |
<table width="200" border="1"> | |
<tbody id="Table1" > | |
<tr> | |
<td>Row1-1 | |
</td><td>Row1-2 | |
</td> | |
</tr><tr> | |
<td>Row2-1 | |
</td><td>Row2-2 | |
</td> | |
</tr><tr> | |
<td>Row3-1 | |
</td><td>Row3-2 | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
<input type="button" name="" value="Remove Last Row" onclick="RemoveRow('Table1');"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment