Development| HTML| JavaScript| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JavaScript createCaption method 
 

In the JavaScript we can add the table's caption dynamically by using the method createCaption().

 

JavaScript createCaption method

                         

In the JavaScript we can add the table's caption dynamically by using the method createCaption(). The createCaption() method is used to create an empty caption element for a table. We can use the property innerHTML onto the created caption object to add the caption with some value.

Syntax: 

   table_Object.createCaption() ;

Description of example:

In the following example code we have created a table which is not having any caption and we will add the caption to this table by using the method createCaption(). We have create a button element in the HTML page which will call the function createCaption() which we have defined in our script tags. To create caption we have used createCaption() method on the table's object and then to add some value to the caption we will use the innerHTML property of the caption object.

Here is the full example code of creating and adding the caption element to the table as described below:

createCaptionExample.html

<html>
 <head>
  <script type="text/javascript">
   function createCaption()
   {
     var cap=document.getElementById('table').createCaption();
     cap.innerHTML="Information";
   }
  </script>
 </head>
<body>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
 <div style="background: #cf2255; 
      width:'100%';" 
      align="center">
      <font color="#ffffcc" 
            size="12pt">
        <b>
            Create Caption Example
        </b>
      </font>
  </div>
  <center>
    <table id="table" 
           border="1" 
           cellspacing="0" 
           cellpadding="3" >
<tr>
<td align="center" bgcolor="#808080">
  <p align="center">Name</p>
</td>
<td align="center">
  <p align="center">Amit</p>
</td>
</tr>
<tr>
<td align="center" bgcolor="#808080">
  <p align="center">Qual</p>
</td>
<td align="center">
  <p align="center">MCA</p>
</td>
</tr>
</table>
  </center>
<p align="center">
<br />
<input type="button" onclick="createCaption();
        this.disabled=true;"
        value="Create caption">
</body>
</html>

Output:

click on the button "Create caption" , it will create and add the table's caption into the table body.

Download Source Code

                         

» View all related tutorials
Related Tags: java javascript c attributes script reference object method sed remove ip attribute node move nat to ref e it alter

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.