jQuery获取表格之间总行数
<table> <tr id="parent_1"> <td>Parent 1</td> </tr> <tr class="child"> <td>Child 1</td> </tr> <tr class="child"> <td>Child 2</td> </tr> ... <tr id="parent_2"> <td>Parent2</td> </tr> ... </table>
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");
相关推荐
zrtlin 2020-11-09
xuebingnan 2020-11-05
wikiwater 2020-10-27
heheeheh 2020-10-19
Crazyshark 2020-09-15
softwear 2020-08-21
ZGCdemo 2020-08-16
jczwilliam 2020-08-16
littleFatty 2020-08-16
idning 2020-08-03
jinxiutong 2020-07-26
lanzhusiyu 2020-07-19
Skyline 2020-07-04
xiaofanguan 2020-06-25
Aveiox 2020-06-23
dragonzht 2020-06-17