Home  >  Article  >  Web Front-end  >  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

零下一度
零下一度Original
2017-06-19 14:23:041509browse

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);

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!

Statement:
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