简体   繁体   English

使用 javascript 隐藏表中的 Class 行

[英]Hide Class Row in table using javascript

The title might sound easy but abit of a complicated question.标题听起来很简单,但问题有点复杂。

I have the following row which is autogenerated via some PHP:我有以下通过一些 PHP 自动生成的行:

<tr class="custom_field-row custom_205_-4-row"></tr>

The Question is:问题是:

How do i hide every instance of this row using Javascript as the no 4 is automatically replaced by other numbers depending on what entry number it is.我如何使用 Javascript 隐藏此行的每个实例,因为第 4 位会自动替换为其他数字,具体取决于它的条目号。 So i need to hide:所以我需要隐藏:

<tr class="custom_field-row custom_205_-***EVERYSINGLEPOSSIBLENUMBER***-row"></tr>

Any Ideas?有任何想法吗? A foreach statement sounds like the best way to go forward but i am not sure where to start. foreach 语句听起来像是 go 前进的最佳方式,但我不知道从哪里开始。

Thanks谢谢

try this with a loop, it should get you all rows with用循环试试这个,它应该让你得到所有行

you can loop through the common part of the class and you can add your on further checks on class Name if you want to make sure its correct class or whatever您可以遍历 class 的公共部分,如果您想确保其正确的 class 或其他名称,您可以添加对 class 名称的进一步检查

$('[class^="abc"]') // starts with string
$('[class$="end"]') // ends with string

$( '[class^="custom_205_"][class$="row"]').each ( function () {
   // hide this.hide() or remove
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM