$(document).ready(function () {
     $(".div_btn").each(function(key,value){
      $(value).click(function(){
      $(this).prev(".div_c").slideToggle();
      if($(this).html() == '隐藏'){
      $(this).html('点击'+(key+1));
      }else{
      $(this).html('隐藏');
      }
      })
     
     })
       
    });

解决方案 »

  1.   


    <!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>无标题文档</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {

    $('.div_btn').each(function(index, element) {
            $(this).attr('content',$(this).html());
        });
         $(".div_btn").click(function(){
     var oDiv=$(this).prev(".div_c");
     if(oDiv.is(":hidden"))
     {
     $(this).html('隐藏');
     }
     else
     {
     $(this).html($(this).attr("content"));
     }
     oDiv.slideToggle();
     })
           
        });
    </script>
    <style type="text/css">
    *{
        margin:0;
        padding:0;
        }
    .div{
        width:200px;
        float:left;
        }
    .div_c{
        width:200px;
    height:100px;
    background:#00BCF3;
        float:left;
    display:none;
        }
    .div_btn{
        width:200px;
        height:30px;
        float:left;
        background:#099;
        color:#FFF;
        line-height:30px;
        text-align:center;
        margin-top:20px;
        cursor:pointer;
        }
    </style>
    </head>
      
    <body>
    <div class="div">
     <div class="div_c"></div>
     <a href="javascript:;" class="div_btn">点击1</a>
     <div class="div_c"></div>
     <a href="javascript:;" class="div_btn">点击2</a>
    </div>
    </body>
    </html>