首頁  >  文章  >  web前端  >  分享一個jQuery取得表格總行數的實例程式碼

分享一個jQuery取得表格總行數的實例程式碼

零下一度
零下一度原創
2017-06-19 14:23:041509瀏覽

例子,jquery取得表格總行數:

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

以上是分享一個jQuery取得表格總行數的實例程式碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn