目录

Drop

描述 (Description)

Drop效果可以与show/hide/toggle一起使用。 这会使元素掉落或通过放下它来显示它。

语法 (Syntax)

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

<i>selector</i>.hide|show|toggle( "drop", {arguments}, speed );

参数 (Parameters)

以下是所有论点的描述 -

  • direction - 效果的方向。 可以是“左”,“右”,“上”,“下”。 默认为左。

  • mode - 效果的模式。 可以“显示”或“隐藏”。 默认是隐藏。

例子 (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" 
         src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js">
      </script>
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
            $("#hide").click(function(){
               $(".target").hide( "drop", {direction: "up"}, 1000 );
            });
            $("#show").click(function(){
               $(".target").show( "drop", {direction: "down"}, 1000 );
            });
         });
      </script>
      <style>
         p {background-color:#bca; width:200px; border:1px solid green;}
      </style>
   </head>
   <body>
      <p>Click on any of the buttons</p>
      <button id = "hide"> Hide </button>
      <button id = "show"> Show</button> 
      <div class="target">
         <img src = "../images/jquery.jpg" alt = "jQuery" />
      </div>
   </body>
</html>

这将产生以下结果 -

新页面打开
↑回到顶部↑
WIKI教程 @2018