不应该把tr数字作为class,因为tr绑定的class有很多,完全可以把数字绑定在data-num上面,大概逻辑就是下面这个,可能部分选择器写的不是那么准确 html table: <table id='example_table'> <thead> <th>1<th> <th>2<th> <th>3<th> </thead> <tbody> <tr data-num="1"> <td>1<td> <td>2<td> </tr> <tr data-num="2"> <td>1<td> <td>2<td> </tr> <tr data-num="3"> <td>1<td> <td>2<td> </tr> </tbody> </table> js: $('#example_table tr').on('click', function(e) { var select_tr_num = $this.data('num'); var request_trs = []; $.each($('#example_table tr'), function(i, obj) { if (!obj.data('num') > select_tr_num) { select_tr_num.push(obj); } }); console.log(request_trs ); });
不应该把tr数字作为class,因为tr绑定的class有很多,完全可以把数字绑定在data-num上面,大概逻辑就是下面这个,可能部分选择器写的不是那么准确
html table:
js: