需要关于PHP/jQuery注释脚本的帮助吗

需要关于PHP/jQuery注释脚本的帮助吗,php,jquery,Php,Jquery,我以前问过这个问题,但我没有发布代码。就这样 <?php require(database.php); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>

我以前问过这个问题,但我没有发布代码。就这样

<?php require(database.php); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.comment-wrap {
    width: 300px;
    overflow: hidden;
    margin-bottom: 10px;
}
.reply {
    overflow: hidden;
    margin-top: 10px;
}
.comment-wrap .replyLink {
    float: right;
}
.comment-wrap .comment {
    float: left;
    margin-left: 5px;
}
.comment-wrap .img {
    background-color: #F00;
    height: 50px;
    width: 50px;
    float: left;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
                $(".reply").hide();
        });
    $(document).ready(function() {
        $('.replyButton').click(function() {
            $(".reply").show();
        });

    });
</script>
</head>

<body>
<?php

$sql= "SELECT * FROM comments";
$result = $database->query($sql);

while($row = mysql_fetch_array($result)) {
    echo '<div class="comment-wrap">';
        echo '<div class="img">' . $row['img'] .'</div>';
        echo '<div class="comment">' . $row['comment'] . '</div>';
        echo '<div class="replyLink">';
        echo '<a href="#" class="replyButton" ">Reply</a></div>';
    echo '</div>';
    echo '<div class="reply">
    Type your message: <br />
      <form id="form1" name="form1" method="post" action="">
            <label for="reply"></label>
            <textarea name="replyMessage" class="replyMessage" cols="45" rows="5"></textarea>
      </form>';
    echo '</div>';
}
?>


</body>
</html>

无标题文件
.评论摘要{
宽度:300px;
溢出:隐藏;
边缘底部:10px;
}
.答复{
溢出:隐藏;
边缘顶部:10px;
}
.comment wrap.replyLink{
浮动:对;
}
.comment wrap.comment{
浮动:左;
左边距:5px;
}
.comment wrap.img{
背景色:#F00;
高度:50px;
宽度:50px;
浮动:左;
}
$(文档).ready(函数(){
$(“.reply”).hide();
});
$(文档).ready(函数(){
$('.replyButton')。单击(函数(){
$(“.reply”).show();
});
});
当用户单击reply按钮时,reply类将在之前隐藏的所有注释上展开。但是我希望reply类仅在用户单击了reply按钮的注释上展开

内容将存储在MySQL数据库中,并通过PHP检索。但这里我只需要jQuery部分的帮助。我不是要完整的代码,只要给我一些提示,我就可以解决它。

将类“toggle”指定给要应用显示/隐藏功能的任何元素,下面是JS

// Andy Langton's show/hide/mini-accordion - updated 23/11/2009
// Latest version @ http://andylangton.co.uk/jquery-show-hide

// this tells jquery to run the function below once the DOM is ready
$(document).ready(function() {

// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='Show';
var hideText='Hide';

// initialise the visibility check
var is_visible = false;

// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.toggle').prev().append(' (<a href="#" class="toggleLink">'+showText+'</a>)');

// hide all of the elements with a class of 'toggle'
$('.toggle').hide();

// capture clicks on the toggle links
$('a.toggleLink').click(function() {

// switch visibility
is_visible = !is_visible;

// change the link depending on whether the element is shown or hidden
$(this).html( (!is_visible) ? showText : hideText);

// toggle the display - uncomment the next line for a basic "accordion" style
//$('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.toggle').toggle('slow');

// return false so any link destination is not followed
return false;

});
});
//Andy Langton的show/hide/mini手风琴-更新日期:2009年11月23日
//最新版本@http://andylangton.co.uk/jquery-show-hide
//这告诉jquery在DOM就绪后运行下面的函数
$(文档).ready(函数(){
//为显示/隐藏链接选择文本-可以包含HTML(例如图像)
var showText='Show';
var hideText='Hide';
//初始化可见性检查
var为可见=假;
//使用“toggle”类将显示/隐藏链接附加到元素前面的元素
$('.toggle').prev().append('()');
//使用“toggle”类隐藏所有元素
$('.toggle').hide();
//捕获切换链接上的单击
$('a.toggleLink')。单击(函数(){
//切换可见性
is_visible=!is_visible;
//根据图元是显示还是隐藏,更改链接
$(this).html((!是否可见)?showText:hideText);
//切换显示-取消注释下一行的基本“手风琴”样式
//$('.toggle').hide();$('a.toggleLink').html(showText);
$(this.parent().next('.toggle').toggle('slow');
//返回false,因此不遵循任何链接目标
返回false;
});
});

文档中应该只有一个元素具有相同的id,因此您可以更改类的id

echo '<a href="#" class="replyButton" ">Reply</a></div>';

这将显示父元素之后的下一个元素。父元素是
.comment wrap
,下一个元素是
.reply

如果我将切换应用于reply类,那么reply类仍将在所有注释上展开,而不是在特定注释上展开。我发布的链接中甚至有一个演示,显示只显示了一个元素,而不是所有元素。
$('.replyButton').click(function() {
   $(this).parent().next().show();
});