jQuery过滤选择器经典应用
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>过滤选择器</title>
- <style type="text/CSS">
- #txt_show {display:none; color:#00C;}
- #txt_hide {display:block; color:#F30;}
- </style>
- <script src1="js/jquery-1.8.3.js"></script>
- <script language="JavaScript">
- $(document).ready(function () {
- $("[name=show]").click(function () {
- $("p:hidden").show();
- }) ;
- $("[name=hide]").click(function () {
- $("p:visible").hide() ;
- });
- });
- </script>
- </head>
- <body>
- <p id="txt_hide">点击按钮,我会被隐藏哦~</p>
- <p id="txt_show">隐藏的我,被显示了,嘿嘿^^</p>
- <input name="show" type="button" value="点击显示文字" />
- <input name="hide" type="button" value="点击隐藏文字" />
- </body>
- </html>
来源: https://www.oschina.net/code/snippet_2887409_58704