[英]Hide show divs with mysql?
我希望能夠在加載時不顯示注釋div,當單擊注釋時,我希望它打開注釋div。
我該怎么做呢? 我環顧四周,但是...閱讀本書后,我得到的所有建議僅適用於一個div,它消除了每個帖子的內容div結果以及您在代碼中看到的單獨注釋。
<?
$data = mysql_query("SELECT `i`.*, `a`.* FROM `Wall` `i` LEFT JOIN `WallComments` `a` ON (`i`.`ID` = `a`.`Comments_ID`) WHERE `i`.`Username` = '{$view}'");
while($Comments = mysql_fetch_array($data)){
$walldate = gmdate('g:i a j F, Y', ($Comments['WallDate']));
$postdate = gmdate('g:i a j F, Y', ($Comments['Date']));
echo
"<div id='Wall'><a class='menuLink' href='Profile.php?view={$Comments['MessageBy']}' onclick='return false;'>{$Comments['MessageBy']}</a> - On: {$walldate}<br />Wrote: {$Comments['Message']}</div><br /><br />
<div id='Wall'><br />Comments<br /><br />{$Comments['CommentUsername']} Commented - On: {$postdate}<br />Wrote: {$Comments['Post']}</div><hr><br />
";
}
?>
每次用戶發表帖子時,它都會在數據庫中插入新行,並在其中添加注釋,因此我需要它自動使divs成為某種事物,而不是讓div id = 1 div id = 2成為某種事物,這就是我得到的內容我在網上看到的所有內容。
誰能幫我?
最初隱藏div:
<div id='Wall' style="visibility: hidden;">
使用JavaScript讓div出現:
<button onclick="document.getElementById('Wall').style.visibility='visible';">
Show
</button>
您可以在錨標記中包含注釋:
<a href="#" onclick="document.getElementById('Wall').style.visibility='visible';">
Comments here
</a>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.