Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 基于类名从每个循环中排除特定行_Javascript_Jquery_Html - Fatal编程技术网

Javascript 基于类名从每个循环中排除特定行

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"

如何使用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")
        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 
      }
 });