[英]Using jQuery to hide/show table row for posting a reply
我正在構建一個公告板系統,我們可以向其發布消息,並且人們可以回復該消息。 我已經發布了一條可以正常工作的新消息,對於每條新消息,我都使用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放在其中,或類似的東西...
糟糕,忘記給您鏈接 http://api.jquery.com/jQuery.ajax/
祝您好運,如果您還有其他問題,請使用[評論]下方的框,如果有任何問題,我會解答
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.