`

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 class="title_a">一、JQuery核心库</div>
        <div class="title_b">(一)、jQuery(e­xpression,[context])用法!</div>
        <div class="title_c">3.jQuery(elements)</div>
        将一个或多个DOM元素转化为jQuery对象。这个函数也可以接收XML文档和Window对象(虽然它们不是DOM元素)作为有效的参数。<p></p>
        
        <input id="btnDisplay" type="button" value="隐藏" onclick="changeDisplay()"/>
        <div id="helloDiv">
        Hello,everyone<p></p>
        Hello,everytwo<p></p>
        Hello,everythree<p></p>
        </div>
    </bdoy>
</html>

 

分享到:
评论
3 楼 爱喝牛奶的娃娃 2011-11-21  
骗人
2 楼 fengzhiyin 2010-06-30  
已修复,错误原因是将js函数的结束}注释了导致。
1 楼 spp_1987 2010-06-24  
报错啊

相关推荐

Global site tag (gtag.js) - Google Analytics