57 lines
1.1 KiB
HTML
57 lines
1.1 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<SCRIPT>
|
|
|
|
function insertIt() {
|
|
var body = document.documentElement.childNodes[1];
|
|
var table = document.getElementsByTagName("TABLE")[0];
|
|
var otherCaption = document.getElementsByTagName("CAPTION")[0];
|
|
var attrList = otherCaption.attributes
|
|
var caption = document.createElement("CAPTION", attrList);
|
|
var text = document.createTextNode("here is the new caption text");
|
|
caption.appendChild(text);
|
|
|
|
table.appendChild(caption);
|
|
}
|
|
|
|
function deleteIt() {
|
|
var body = document.documentElement.childNodes[1];
|
|
var table = document.getElementsByTagName("TABLE")[0];
|
|
var caption = document.getElementsByTagName("CAPTION")[0];
|
|
table.removeChild(caption);
|
|
}
|
|
|
|
|
|
|
|
|
|
</SCRIPT>
|
|
</HEAD>
|
|
|
|
<BODY>
|
|
<table border>
|
|
<tbody>
|
|
<tr>
|
|
<td>table without a caption</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<form>
|
|
<INPUT TYPE="button" NAME="Ins" VALUE="Insert" onClick="insertIt()">
|
|
<INPUT TYPE="button" NAME="Del" VALUE="Delete" onClick="deleteIt()">
|
|
</form>
|
|
<br><br>
|
|
<table border>
|
|
<caption style="border: 2px solid black">here is a caption</caption>
|
|
<tbody>
|
|
<tr>
|
|
<td>table with a caption</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
|
|
</BODY>
|
|
</HTML>
|
|
|
|
|