Jquery 选择表td在索引之间的范围索引
每行td介于02~04之间。是,您可以通过以下方式执行:Jquery 选择表td在索引之间的范围索引,jquery,html,Jquery,Html,每行td介于02~04之间。是,您可以通过以下方式执行: $('table td').css('color' ,'red'); 片段 $(函数(){ $(“表tr”)。每个(函数(){ $(this.find(“td:gt(0)”).css('color','red'); }); }); 00 01 02 03 00 01 02 03 您可以使用 将匹配的元素集减少为与选择器匹配或通过函数测试的元素集 $(函数(){ $(“表td”).filter(函数(){ var te
$('table td').css('color' ,'red');
片段
$(函数(){
$(“表tr”)。每个(函数(){
$(this.find(“td:gt(0)”).css('color','red');
});
});代码>
00 01 02 03
00 01 02 03
您可以使用
将匹配的元素集减少为与选择器匹配或通过函数测试的元素集
$(函数(){
$(“表td”).filter(函数(){
var text=parseInt($(this).text(),10);
返回text>=2&&text=2&&text只是为了确认,索引
或值
?@Satpal:我怀疑这是否重要。文本值仅基于索引。。。
$('table td').css('color' ,'red');
$(function () {
$("table tr").each(function () {
$(this).find("td:gt(0)").css('color' ,'red');
});
});
$(function () {
$("table td").filter(function () {
var text = parseInt($(this).text(),10);
return text >= 2 && text <= 4;
}).css('background-color' ,'red');;
});