【发布时间】:2014-10-08 23:36:43
【问题描述】:
我在一页上有多个表格和来自array_keys 的一组数字。
我为每个<tr> 赋予了一个递增的ID,从0 开始。如果我的数组返回0、1、3、5,我希望隐藏ID 为2 和4 的<tr>。通常我会使用 CSS 并应用样式:display=none。
我想我需要在这样的数组循环中使用 jQuery .find():
$arr = array_keys($floor_item, $po); //floor_item is my array & po is the value I'm searching
foreach($arr as $key => $item){
print "<tr id='" . $item . "'><td>" . $item . "</td></tr>"; //this will show me the id's I want
//just guessing here
$( "tr" ).find( "$item" ).hide();
}
【问题讨论】:
-
纯数字 ID 是 HTML 5 的一项功能...最好为它们添加前缀并使用 `$('tr[id^=myprefix]') 匹配前缀
-
你不能在php代码中使用jQuery。
标签: javascript php jquery html arrays