$(document).ready(function () {
            $(".question").click(function () {
                $(".answer").toggle(300);
            });
        });顺便说一句:你的html代码一点也不漂亮

解决方案 »

  1.   

    您这代码我点击div是question的时候的确dive=answer的展开了,但是我如果点击div=answer里面的链接后,div=answer的就是消失了。这不是我要的效果,我是要点击div=question后才能消失。这个html我是用dreamweaver自动创建的,不是我自己写的。谢谢您的代码,能否实现以上那个效果?
      

  2.   

    自己搞定了。可以实现我想要的效果,供大家参考。
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>FAQ</title>
    <link href="_css/qa.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    .question {
    cursor: pointer;
    }
    </style>
    <script src="_js/jquery-1.11.1.min.js"></script>
    <script>
    $(document).ready(function(){
     $(".answer").hide();
     $(".question").click(function(){
     if($(this).children(".answer").is(":visible")==false){
      $(this).children(".answer").fadeIn(300);
     }else{
    $(this).children(".answer").hide();
     }
     });
     $(".answer").click(function(){
     $(this).hide();
     }
     ); // end click
    }); // end ready
    </script></head>
    <body class="YaHei"><div class="question" > 
     <table width="100%" border="0" align="center" cellspacing="0">
      <tr>
        <th height="30" align="left" nowrap="nowrap" bgcolor="#FFC423" class="cell" scope="col">       1. 订单操作邮件(针对客户订单重新预约上门取件、取消)</th>
      </tr>
     </table>
    <div class="answer">
    <table width="100%" border="0" align="center" cellspacing="0">
      <tr>
        <td bgcolor="#CCCCCC"><a href="email/1-1.html" target="mainFrame">1.1 订单取消邮件模板</a></td>
      </tr>
    </table>
    </div>
    </div>
    <br />
    </body>
    </html>
      

  3.   


    toggle就可以切换了。不必hide和fadeIn。