2011-09-25 7 views
0

다음 jquery가 있습니다. 사용자가 .commentCount를 클릭하면 #commentSec이라는 div가 열리 며 사이트의 다른 요소가 변경됩니다. 이 jquery 청크가 잘 실행됩니다. 그러나 두 번째 청크, .closeComments라는 닫기 버튼의 onclick은 전혀 실행되지 않습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 첫 번째 jquery 섹션에서 true 또는 something을 반환해야합니까? 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)'display : none'과'display : block'을 설정하는 대신 jQuery'.show()'와'.hide()'를 사용하십시오. 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

오, 고마워,하지만 아직 아무것도 안 해. –

관련 문제