我点按钮第一下的时候,显示下面隐藏的DIV,我再点就把DIV隐藏起来了,再去点,他也就打开了!要滑动门效果!求一段代码~

解决方案 »

  1.   

    用jQuery来写吧,http://api.jquery.com/toggle/
    更复杂的效果可以使用jQueryUI插件:http://jqueryui.com/demos/toggle/#default
      

  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>无标题文档</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready( function() {
    $("#btn").click( function() { $(".d1").toggle('fast'); });
    });
    </script>
    </head><body>
    <input type="button" id="btn" value="按钮" />
    <div class="d1" style="width:200px; border:1px solid #999; background-color:#39F; color:#FFF; display:none;">
    我点按钮第一下的时候,显示下面隐藏的DIV,我再点就把DIV隐藏起来了,再去点,他也就打开了!要滑动门效果!求一段代码~
    </div>
    </body>
    </html>
      

  3.   


    //假如按钮id为btn1,div的id为div1<script>
    $(function(){
        $("#btn1").click(
             function(){
                 $("#div").toggle();
             })
    })
    </script>