aspx Tutorial

NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Tuesday, December 21, 2010 Total Views:  

In this example, i have told you that how to display number of column(s) in a table using jQuery. This is very simple using jQuery,

Here’s is an example

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <title>Display number of column(s) in a Table using jQuery</title>
   <script src="http://code.jquery.com/jquery-1.4.3.min.js" type="text/javascript"></script>
   <script type="text/javascript">
       $(document).ready(function () {
           CountColumn = function (T) {
               return $(T).find('tr')[0].cells.length;
           }

           $("#msg").text("Total column(s): " + CountColumn("#table1"));
       });    
   </script>
   <style type="text/css">
       body
       {
           font-family: Verdana;
           font-size: 12px;
       }
       table
       {
           width: 500px;
       }
       td
       {
           width: 25px;
           border-bottom: 1px solid #eaeaea;
           padding-left: 10px;
       }
       th
       {
           border-top: 1px solid #eaeaea;
           border-bottom: 1px solid #eaeaea;
       }
   </style>
</head>
<body>
   <form id="form1" runat="server">
   <div>
   <h2>Display length of column(s) in a Table using jQuery</h2>
       <table id="table1" cellpadding="0" cellspacing="0">
           <tr>
               <th>
                   Sr.
               </th>
               <th>
                   Full Name
               </th>
               <th>
                   Age
               </th>
               <th>
                   Gender
               </th>
               <th>Location</th>
           </tr>
           <tr>
               <td>1</td>
               <td>Aamir Hasan</td>
               <td>20</td>
               <td>M</td>
               <td>PK</td>
           </tr>
           <tr>
               <td>2</td>
               <td>Awais Ahmed</td>
               <td>18</td>
               <td>M</td>
               <td>PK</td>
           </tr>
           <tr>
               <td>3</td>
               <td>Saba Hasan</td>
               <td>24</td>
               <td>F</td>
               <td>AM</td>
           </tr>
       </table>
   </div>
   <p>&nbsp;</p>
   <div id="msg">&nbsp;    </div>
   </form>
</body>
</html>

Download

Table column length.zip (1.30 kb)

Live demo

Protected by Copyscape Online Plagiarism Tool

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5