jQuery获取表格之间总行数

阅读更多

  ...
  
  ...
Parent 1
Child 1
Child 2
Parent2


var childCount = ($('#parent_2').get(0).rowIndex - $('#parent_1').get(0).rowIndex) - 1;


$('#parent_1 ~ .child:not(#parent_2 ~ *)').size();


var rowid1 = 'parent_1';
var rowid2 = 'parent_2';

var rows = $("#"+rowid1).parent().find('tr');
var count = 0;

for (var i = 0; i < rows.size(); i++) {
    var el = rows.get(i);

    // Done counting
    if (el.id == rowid2) break;

    if (el.id != rowid1) {
        ++count;
    }
}

alert("There are " + count + " rows between");

你可能感兴趣的:(乔乐共享,jQuery,table,rows,size)