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" >← previous answer</a><a class="next" href="">next answer →</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"/>
向我們顯示您的HTML。然後,有幾件事需要改進:1)使用jQuery'.show()'和'.hide()'而不是設置'display:none'和'display:block'。 2)不透明度是從0到1.0的值。 「9」對於不透明度不是合法價值。 – jfriend00
[jquery chunk not running]的可能重複(http://stackoverflow.com/questions/7547372/jquery-chunk-not-running) –
請不要發表相同的問題兩次。 –