使用prototype/scriptaculous隐藏前一行
我不知道这是否可能,但我有一种情况,我需要能够隐藏上一个表行加载。
情况:
<table>
<tr>
<td>1</td>
<td>a</td>
</tr>
<tr>
<td>2</td>
<td>b</td>
</tr>
<tr id="removeabove">
<td>3</td>
<td>c</td>
</tr>
</table>
现在我再次不知道这是否可能,到目前为止还没有找到它,但是当我将 id removeabove
放在一行中时,我希望前一行消失并消失(显示:无;)
提前Tnx
I dont know if this is even possible, but I have a situation where I need to be able to hide the previous table row onload.
Situation:
<table>
<tr>
<td>1</td>
<td>a</td>
</tr>
<tr>
<td>2</td>
<td>b</td>
</tr>
<tr id="removeabove">
<td>3</td>
<td>c</td>
</tr>
</table>
Now again I dont know if this is even possible, havent found it so far, but when I put the id removeabove
in a row, I want the previous row to go poof and be gone (display: none;)
Tnx in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当将 ID 放在行上时,我假设您有一个指向该行元素的变量。如果是这样,您可以像这样隐藏上一行:(
如果不这样做,只需在上面加上
var myrow = $('removeabove');
) Element#previous 为您提供 DOM 中的上一个同级元素,如果没有,则为未定义。您还可以使用 CSS 选择器来仅匹配与选择器匹配的前一个元素,但这对于您正在做的事情似乎没有必要。如果您希望该行真正消失(而不仅仅是隐藏),您可以使用
remove
而不是hide
,但您特别提到了“显示” : none" 这就是hide
的作用,所以......When putting the ID on the row, I assume you have a variable pointing to the row's element. If so, you can hide the previous row like this:
(And if you don't, just precede the above with
var myrow = $('removeabove');
) Element#previous gives you the previous sibling element in the DOM, or undefined if there isn't one. You can also use a CSS selector with it to only match a previous element matching the selector, but that didn't seem necessary for what you were doing.If you want the row to really be gone (not just hidden), you can use
remove
instead ofhide
, but you specifically mentioned "display: none" which is whathide
does, so...