JavaScript DHTML/Table/Caption

Материал из Web эксперт
Перейти к: навигация, поиск

Caption Vertical Align

   <source lang="html4strict">
   

<html> <body>

<script language="JavaScript"> document.all.myCaption.vAlign = "bottom"; </script>
Table 2-5. This is the caption for this table.
Cell 1 Cell 2
Cell 3 Cell 4

</body> </html>


     </source>
   
  


Create a Caption

   <source lang="html4strict">
   

<html> <body> <script language="JavaScript"> function function1() {

   var myC = document.getElementById("myT").createCaption();
   myC.innerText = "This is the new caption text";

} </script>

This table has no caption

<input id="myT" type="button" value="Add caption" onclick="function1();"> </body> </html>


     </source>
   
  


Delete a Caption

   <source lang="html4strict">
   

<html> <body> <script language="JavaScript"> function function1() {

   document.all.myT.deleteCaption(); 

} </script>

This is the caption element
Cell 1 Cell 2

<input type="button" value="Remove caption" onclick="function1();"> </body> </html>


     </source>
   
  


Get caption from table object

   <source lang="html4strict">
   

<html> <body id="myBody">

Cell 1 Cell 2 Cell 3
Cell 1 Cell 2 Cell 3
Cell 1 Cell 2 Cell 3

<button onclick="alert(document.all.myTable.caption);">Table Caption</button> </body> </html>


     </source>
   
  


Table Caption align Example

   <source lang="html4strict">
   

<html> <head> <script language="JavaScript">

   function function1() {
       document.all.myCaption.align = event.srcElement.id;
   }

</script> </head> <body>

This is the caption text for the table
Cell 1 Cell 2
Cell 3 Cell 4


<input type="Button" id="bottom" value="align "bottom"" onClick="function1();"> <input type="Button" id="left" value="align "left"" onClick="function1();"> <input type="Button" id="right" value="align "right"" onClick="function1();"> <input type="Button" id="top" value="align "top"" onClick="function1();"> </body> </html>


     </source>