Javascript 基于类名从每个循环中排除特定行
如何使用Jquery根据特定行的类名排除该行Javascript 基于类名从每个循环中排除特定行,javascript,jquery,html,Javascript,Jquery,Html,如何使用Jquery根据特定行的类名排除该行 filterBySensor= function (event) { j("#example tr").hide(); //hide all rows j("#example tr:first").show(); var snsrname = j("#ulsensor option:selected").text(); //retrieve wanted status if(snsrname == "All"
filterBySensor= function (event) {
j("#example tr").hide(); //hide all rows
j("#example tr:first").show();
var snsrname = j("#ulsensor option:selected").text(); //retrieve wanted status
if(snsrname == "All")
j("#example tr").show(); //show all rows if want to see All
else {
j("#example tr").each(function() { //loop over each row
var celldata = j.trim(j(this).find("td:eq(4)").text());
if(celldata == snsrname) { //check value of TD
j(this).show(); //show the row
}
});
}
}
上面的代码工作正常,并检查表中的每一行。
但是我想根据它的类名排除一些行。
例如:有3行带有类名组,我需要将它们从循环中排除。任何帮助都将不胜感激。Thanx提前尝试使用jQuery的.not()
方法:-
j("#example tr").not(".group").each(function() { //loop over each row except for rows having group class name.
var celldata = j.trim(j(this).find("td:eq(4)").text());
if(celldata == snsrname) { //check value of TD
j(this).show(); //show the row
}
});
或(您可以按以下方式使用而不是
)
j("#example tr:not(.group)").each(function() { //loop over each row except for rows having group class name.
var celldata = j.trim(j(this).find("td:eq(4)").text());
if(celldata == snsrname) { //check value of TD
j(this).show(); //show the row
}
});