读书人

JQuery展示隐藏DIV (一)

发布时间: 2012-11-22 00:16:41 作者: rapoo

JQuery显示隐藏DIV (一)

<!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=gbk" />        <title>StripingTable</title>        <script type="text/javascript" src="http://www.wozaishuo.com.cn/example/jquery/jquery-1.2.1.js"></script>        <script type="text/javascript">        <!--            $(document).ready(function(){ });                        //隐藏和显示div层            function changeDisplay(){                var helloDivObj = $("#helloDiv");                var buttonObj = $("#btnDisplay");                var val = buttonObj.attr("value");                if(val=="隐藏"){                    helloDivObj.hide();                    buttonObj.attr("value","显示");                }else{                    helloDivObj.show();                    buttonObj.attr("value","隐藏");                }                          // var helloDivObj = $("#helloDiv").toggle(); //甚至只需要这一句搞定切换隐藏与显示            }        -->        </script>    </head>    <body>        <div type="button" value="隐藏" onclick="changeDisplay()"/>        <div id="helloDiv">        Hello,everyone<p></p>        Hello,everytwo<p></p>        Hello,everythree<p></p>        </div>    </bdoy></html>

?

骗人

读书人网 >Web前端

热点推荐