2011-09-25 64 views
0

我在下面有jquery。当用户点击.commentCount时,我希望这个名为#commentSec的div打开,然后网站上的其他元素发生变化。这jquery块运行良好。但是,第二个块,即一个名为.closeComments的关闭按钮的onclick,根本不运行。我究竟做错了什么?我是否必须在第一个jquery部分返回true或者什么? Thanks--第二个jquery“chunk”没有运行

$('.commentCount').click(function() { 
     $('#commentSec').css({ 'display' : 'inline', 'height' : 'auto', 'padding' : '10px', 'padding-bottom' : '0px', 'margin-bottom' : '10px', 'margin-left' : '10px', 'z-index' : '10'}); 
     $('#commentSec h3').css({ 'display' : 'block'}); 
     $('#rightcolumn').css({ 'opacity' : '.3'}); //Transparent rightcolumn 
    }); 

第二区块:

$('.closeComments').click(function() { 
    $('#commentSec').css({ 'display' : 'none'}); 
    $(this).css({'opacity' : '.9'}); 
    $('#rightcolumn').css({ 'opacity' : '1'}); //Undo transparent rightcolumn 
}); 

HTML/PHP:

<h3><b>' . $useranswering . '\'s</b> ANSWER</h3><img class="closeComments" src="../Images/bigclose.png" alt="close"/> 
    <span><a class="prev" >&larr; previous answer</a><a class="next" href="">next answer &rarr;</a></span> 
    <div> 
    <p>' . $answer . '</p> 
    <form method=post> 
      <input type="hidden" value="'. $ansid .'" name="answerid"> 
      <textarea rows="2" cols="33" name="answercomment">Comment on this answer</textarea> 

      <input type="image" src="../Images/commentSubmit.png"/> 
+2

向我们显示您的HTML。然后,有几件事需要改进:1)使用jQuery'.show()'和'.hide()'而不是设置'display:none'和'display:block'。 2)不透明度是从0到1.0的值。 “9”对于不透明度不是合法价值。 – jfriend00

+0

[jquery chunk not running]的可能重复(http://stackoverflow.com/questions/7547372/jquery-chunk-not-running) –

+0

请不要发表相同的问题两次。 –

回答

0

第三行的第二块的: $(本)的.css({'不透明':'9'});

如果不是: $(this).css({'opacity':'0'});

+0

哦谢谢,但它仍然没有运行任何东西。 –