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

Fold

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

描述 (Description)

Fold效果可与show/hide/toggle一起使用。 这将元素折叠成一张纸。

语法 (Syntax)

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

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

参数 (Parameters)

以下是所有论点的描述 -

  • horizFirst - 首先是否水平折叠。 可以是真是假。 默认值为false。

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

  • size - 要折叠的尺寸。 默认值为15。

例子 (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( "fold", {horizFirst: true }, 2000 );
            });
            $("#show").click(function(){
               $(".target").show( "fold", {horizFirst: true}, 2000 );
            });
         });
      </script>
      <style>
         p {background-color:#bca; width:200px; border:1px solid green;}
         div{ width:100px; height:100px; background:red;}
      </style>
   </head>
   <body>
      <p>Click on any of the buttons</p>
      <button id = "hide"> Hide </button>
      <button id = "show"> Show</button> 
      <div class = "target">
      </div>
   </body>
</html>