当前位置: 首页 > 文档资料 > jQuery 入门教程 >

show()

优质
小牛编辑
121浏览
2023-12-01

描述 (Description)

show( )方法只显示隐藏的每个匹配元素。 这种方法的另一种形式是控制动画的速度。

语法 (Syntax)

以下是使用此方法的简单语法 -

<i>selector</i>.show( );

参数 (Parameters)

以下是此方法使用的所有参数的说明 -

  • NA

例子 (Example)

以下是一个简单的例子,简单地显示了这种方法的用法 -

<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
            $("#show").click(function () {
               $(".mydiv").show();
            });
            $("#hide").click(function () {
               $(".mydiv").hide();
            });
         });
      </script>
      <style>
         .mydiv{ margin:10px;padding:12px; 
            border:2px solid #666; width:100px; height:100px;}
      </style>
   </head>
   <body>
      <div class = "mydiv">
         This is a SQUARE.
      </div>
      <input id = "hide" type = "button" value = "Hide" />   
      <input id = "show" type = "button" value = "Show" />
   </body>
</html>