Home > Web Front-end > JS Tutorial > Share an example code for getting the total number of rows in a table using jQuery

Share an example code for getting the total number of rows in a table using jQuery

零下一度
Release: 2017-06-19 14:23:04
Original
1571 people have browsed it

Example, jqueryGetTableTotal number of rows:

var row
Count
 = $('#myTable tr').length;  
var rowCount = $('#myTable >tbody >tr').length;  
$("#myTable").attr('rows').length;  
var rowCount = $('table#myTable:last').index() + 1;  
//Helper function that gets a count of all the rows <TR> in a table body <TBODY>  
$.fn.rowCount = function() {  
    return $(&#39;tr&#39;, $(this).find(&#39;tbody&#39;)).length;  
};  
  
// USAGE:  
var rowCount = $(&#39;#productTypesTable&#39;).rowCount();  
alert(jQuery("#jtkList").find("table").eq(0).find("tr").length);
Copy after login

The above is the detailed content of Share an example code for getting the total number of rows in a table using jQuery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template