i have a JavaScript to toggle show/hide a div class. The content of the div and the button to activate the toggle function is in a while loop. at first i used "div id" in my JavaScript but that didn't work, i decided to use "div class" instead which worked just fine. However I've not been successful in hiding the div by default, I've tried using display:none and visibility:hidden in my CSS, but that doesn't work at all (content is always hidden). How can i make the div hidden by default using my current JavaScript below:
JavaScript
<script language="JavaScript">
$(document).ready(function(){
$(".Comment").click(function(){
$(this).next(".reply").slideToggle("slow");
});
});
</script>
file.php
<?php
.......................
while($obj = $stmt->fetch())
{
$username = $obj['user_name'];
$comment = $obj['comment'];
$id = $obj['id'];
$userimage = $obj['user_image'];
echo '<div class="comment-item">';
echo '<div class="comment-avatar">';
echo '<img src="user/user_images/'.$userimage.'" alt="avatar">';
echo '</div>';
echo '<div class="comment-post">';
echo '<span style="font-weight:bold;">'.$username.'  said...
</span>';
echo '<p>'.$comment.'</p>';
echo ' <div class="Comment"><input type="button"value="Reply" ></div>';
echo '<div class="reply">';
echo '<form action="" method="post" class="reply"
enctype="multipart/form- data">';
echo '<textarea rows="4" name="txtcomment" style="float:right;resize:
none;margin-top:5px;" cols="50" >';
echo '</textarea>';
echo '</form>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
?>