是否可以在jquery标准中使用more运算符 例如,我想获得rowindex超过某个值的所有行。 有可能以某种方式或者我需要创建自己的函数,一旦我从jquery获得结果集吗?
答案 0 :(得分:3)
对于问题中提到的示例,您只需使用:gt()
选择器:
// Get all rows with a rowIndex greater than 5:
var rowsPlus5 = $('#mytable tr:gt(5)');
对于其他方案,您可能需要将.filter()
方法与回调函数一起使用。
答案 1 :(得分:1)
var $filtered = $('table').find('tr').filter(function(){
return (this.rowIndex > 5);
});
作品。
它不适用于$('table').children('tr')
,我不知道为什么不呢。有人请吗?
答案 2 :(得分:0)
我会尝试类似以下内容:
$('tr.selector').each(function(){
var rowId = $(this).index();
if (rowId > 5){
$(this).addClass('red');
}
});
答案 3 :(得分:0)
.slice( start, [ end ] ); 将匹配元素集减少到由一系列索引指定的子集。
start 表示从0开始的整数 元素之后的位置 选择。如果为负数,则表示为 偏离集合的末尾。
结束 整数表示从0开始 位置之前的元素 停止被选中。如果是否定的话 表示距离结尾的偏移量 集合。 If omitted, the range continues until the end of the set