麻烦与jQuery的

问题描述:

附加形式这里是我的代码:麻烦与jQuery的

$('.reply').click(function() { 
    $leftwrap = $(this).parent(); 
    $comment = $(leftwrap).parent(); 
    $id = $comment.attr('id'); 
    if($(this).siblings('.reply-form').length == 0) { //check whether or not the form as been initiated yet 
    $(this).parent().append('<?php $replytimestamp = strtotime("now"); ?> 
    <form class="reply-form" action="/scripts/reply-process.php" method="post"> 
    <input type="hidden" name="replytimestamp" value="<?php echo $replytimestamp; ?>"> 
    <input type="hidden" name="replyto" value="'+ $id +'"> 
    <label for="name" class="reply-label">Name</label> 
    <input type="text" name="name" class="reply-input"> 
    <label for="message" class="reply-label">Reply</label> 
    <textarea name="message"class="reply-ta"></textarea> 
    <input class="reply-submit" type="submit" name="submit" value="submit" /> 
    </form>'); 
    $(this).siblings('.reply-form').hide(); 
    $(this).siblings('.reply-form').slideDown(); 
} else $(this).siblings('.reply-form').slideToggle(); //if it is, toggle it 

}); 

当过我点击“回复”没有任何反应,没有幻灯片,什么都没有。我在Firebug中找不到任何东西。那么有什么想法是什么?谢谢!!

我会用括号内为建议总是你的if语句,但无论如何,你的问题就在这里:

$leftwrap = $(this).parent(); 
$comment = $(leftwrap).parent(); 

如果你要做到这样,那就必须:

$leftwrap = $(this).parent(); 
$comment = $leftwrap.parent(); 

$变量不是魔术,它的变量名称的一部分,所以你必须包括它。

+0

好吧,我从来没有清楚地了解何时使用“$”。谢谢!! – williamg 2009-12-23 23:54:31