jQuery显示hide和隐藏hide

来源:互联网 发布:火葬场 知乎 编辑:程序博客网 时间:2024/06/07 23:26

这仅仅是自己的学习笔记,只为记录自己的成长。


<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>hide and show</title>    <style type="text/css">         div.ex        {        background-color:#e5eecc;        padding:7px;        border:solid 1px #c3c3c3;        }    </style>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>    <script>        $(document).ready(function(){            $(".ex .hide").click(function(){                $(this).parent().children("p").hide(1000);                            });            $(".ex .show").click(function(){                $(this).parent().children("p").show("slow");                            });            $(".ex .showhide").click(function(){                $(this).parent().children("p").toggle(1000);            })        })    </script></head><body>    <h3>中国办事处</h3>    <div class="ex">        <p>联系人:张先生<br />         北三环中路 100 号<br />        北京</p>        <button class="hide" type="button">隐藏</button><br />        <button class="show" type="button">显示</button><br />        <button class="showhide">显示/隐藏</button>    </div>    <h3>美国办事处</h3>        <div class="ex">                <p>联系人:David<br />         第五大街 200 号<br />        纽约</p>        <button class="hide" type="button">隐藏</button><br />        <button class="show" type="button">显示</button><br />        <button class="showhide">显示/隐藏</button>    </div></body></html>


原创粉丝点击