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 can we count the number of row(s) in a table using jQuery. This is very simple using jQuery,

Here’s is an example

<head runat="server">
   <title>Get no. of rows 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 () {
           CountRow = function (T) {
               return $(T + " tr").length;
           }

           $("#msg").text("Total row(s): " + CountRow("#table1"));
       });    
   </script>
   <style type="text/css">
       body
       {
           font-family: Verdana;
           font-size: 11px;
       }
       table
       {
           width: 400px;
       }
       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>
       <table id="table1" cellpadding="0" cellspacing="0">
           <tr>
               <th>
                   Sr.
               </th>
               <th>
                   Full Name
               </th>
               <th>
                   Age
               </th>
               <th>
                   Gender
               </th>
           </tr>
           <tr>
               <td>1</td>
               <td>Aamir Hasan</td>
               <td>20</td>
               <td>M</td>
           </tr>
           <tr>
               <td>2</td>
               <td>Awais Ahmed</td>
               <td>18</td>
               <td>M</td>
           </tr>
           <tr>
               <td>3</td>
               <td>Saba Hasan</td>
               <td>24</td>
               <td>F</td>
           </tr>
       </table>
   </div>
   <p>&nbsp;</p>
   <div id="msg">&nbsp;    </div>
   </form>
</body>
</html>

Download

Display Table Rows Length.zip (1.25 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