createCaption method (table)
If captions already exists on the current table, the createCaption method returns the first of them and does not create a new one.
Note: a table element may have more than one caption in Internet Explorer and Opera, and at most one caption in Firefox, Google Chrome and Safari.
Note: another way to create a caption is to use the createElement method.
Syntax:
You can find the related objects in the Supported by objects section below.
Return value:
Returns the newly created or an existing caption element.
Example HTML code 1:
This example illustrates the use of the createCaption method:
|
||||
<head> <script type="text/javascript"> function CreateCaption () { var table = document.getElementById ("myTable"); var myCaption = table.createCaption (); myCaption.innerHTML = "<b>Caption for the table.</b>"; } </script> </head> <body> <table id="myTable" border="1px"> <tbody> <tr> <td>This text is inside the table.</td> </tr> </tbody> </table> <br /><br /> <button onclick="CreateCaption ();">Create caption for the table!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
Related pages:
External links:
User Contributed Comments