使用jQuery隐藏/显示用于发布回复的表行



我正在构建一个公告板系统,我们可以向它发布消息,人们可以回复消息。我发布了一条工作正常的新消息,对于每一条新消息,我都使用AJAX为每条消息创建一个新的表行:

<table id="content-table">
<tr>
  <th scope="col" class="messagetime"> <? echo $time; ?> </th>
  <th scope="col" class"message body"></th>
  <th scope="col" class="messagereply"><form method="GET" action="Rindex.php"><input name="id" type="hidden" value="<? echo $id; ?>"><button type="submit" style="border-style:none;" class="post-icon" /></form></th>
</tr>
</table>

在最后一列中,我有一个他们按下的图像,我希望jQuery在这个图像下面创建一个新的表行,其中包含用于输入回复消息的字段,该消息将发布到该特定消息。

我目前可以为每条消息获取一个新行,并隐藏/显示所有消息,但我不知道如何获取回复按钮以针对回复消息的唯一行:

<table id="content-table">
<tr>
  <th scope="col" class="messagetime"> <? echo $time; ?> </th>
  <th scope="col" class"message body"></th>
  <th scope="col" class="messagereply"><form method="GET" action="Rindex.php"><input name="id" type="hidden" value="<? echo $id; ?>"><button type="submit" style="border-style:none;" class="post-icon" /></form></th>
</tr>
<tr id="replyrow" class="replyrow">
 <th scope="col"></th>
 <th scope="col" class="replyrowcontent"> <Post Reply Form would be in here.> </th>
 <th scope="col"></th>
</tr>
</table>

有什么建议吗?我有一种感觉,父母/孩子的关系会涉及到一些事情,但我在脑海中对此有概念!

<div stlye="disply:none;" id="hidden">
    Hidden
</div>

<script>
$.ajax({
   /* ... other options here... */
   success: function (){
       $('#hidden').show();
   }
});
</script>

现在显然你需要一些研究。。。此外,您还可以使用click()方法并将ajax放在那里,或者类似的东西。。。

Oops忘记给你链接http://api.jquery.com/jQuery.ajax/

祝你好运,如果你有更多问题,请使用下面的[评论]框,如果有,我会回答你的问题

最新更新