<p>
                                            <a href="#" class="blue expand_comment"><img src="../../imgs/comment_ico.png" alt="" />3条评论</a>
                                            <!--test-->
                                            <div class="comment_content">
                                                   <div><img src="../../imgs/arrow_com.jpg" alt="" /></div>
                                                   <div class="friend_words">
                                                      <ul>
                                                        <li><img src="../../imgs/friend_photo_small.jpg" alt="" /></li>
                                                        <li><a href="#">施拉格</a></li>
                                                        <li>我也在看</li>
                                                        <li><span>2010-08-30</span></li>
                                                      </ul>
                                                      <ul>
                                                        <li><img src="../../imgs/friend_photo_small.jpg" alt="" /></li>
                                                        <li><a href="#">马琳</a></li>
                                                        <li>太晚了。不看!!</li>
                                                        <li><span>2010-08-30</span></li>
                                                      </ul>
                                                      <p>
                                                      <input type="text" class="leave_words" value="我也说两句"/>
                                                      <br/>
                                                     <div class="btn_position btn_blue">
                                                           <button type="button">我要留言</button>
                                                     </div>
                                                      </p>
                                                   </div>
                                               </div>
                                         <!--test-->
                                         </p> js$(document).ready(function(){
 $(".expand_comment").toggle(function(){
  $(this).text("收起回复");
  $(this).parent("p").children(".comment_content").fadeIn("slow");
  //$(".comment_content").fadeIn("slow");
 },function(){
 $(this).text("展开回复!");
 $(this).parent("p").children(".comment_content").fadeOut("slow");
 });
 
 })
不晓得为什么没有起作用!
求指点!

解决方案 »

  1.   

    这个子容器的获取没关系
    你的html有问题
    在p中包含DIV是错误的做法
    很多浏览器在解析的时候会这样做
    <p>
                                                <a href="#" class="blue expand_comment"><img src="../../imgs/comment_ico.png" alt="" />3条评论</a></p>
                                                <!--test-->
                                                <div class="comment_content">
                                                       <div><img src="../../imgs/arrow_com.jpg" alt="" /></div>
                                                       <div class="friend_words">
                                                          <ul>
                                                            <li><img src="../../imgs/friend_photo_small.jpg" alt="" /></li>
                                                            <li><a href="#">施拉格</a></li>
                                                            <li>我也在看</li>
                                                            <li><span>2010-08-30</span></li>
                                                          </ul>
                                                          <ul>
                                                            <li><img src="../../imgs/friend_photo_small.jpg" alt="" /></li>
                                                            <li><a href="#">马琳</a></li>
                                                            <li>太晚了。不看!!</li>
                                                            <li><span>2010-08-30</span></li>
                                                          </ul>
                                                          <p>
                                                          <input type="text" class="leave_words" value="我也说两句"/>
                                                          <br/>
                                                         <div class="btn_position btn_blue">
                                                               <button type="button">我要留言</button>
                                                         </div>
                                                          </p>
                                                       </div>
                                                   </div>
                                             <!--test-->
                                           <p>  </p> 
      

  2.   


    $(".expand_comment").toggle(function(){
              $(this).text("收起回复");
      $(this).parent().parent().children(".comment_content").fadeIn("slow");
             },function(){
                 $(this).text("展开回复!");
               $(this).parent().parent().children(".comment_content").fadeOut("slow");
       });
      

  3.   

    你的做法可行,但是没说出本质,对XHTML来说,这种做法是危险的~
      

  4.   

    将最外层的p换成div,并且将parent("p")改成parent(),也就是把参数去掉。
    因为在p标签内并不能找到div,你可以在代码中插入这么一句看下就知道了
    alert($(this).parent()[0].outerHTML);
      

  5.   

    我没看他的HTML。
    你说的是很有道理的。
    要遵循规范。