jQuery 中的 Fold方法函数

首页 / jQuery入门教程 / jQuery 中的 Fold方法函数

Fold 效果可以与show/hide/toggle一起使用。这样可以像折叠纸一样折叠元素。

Fold - 语法

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

这是所有参数的描述-

  • horizFirst  - 是否先水平折叠。可以是true或false。默认值为false。

  • model        - 效果的模式。可以是"显示(show)"或"隐藏(hide)"。默认值为hide。

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

Fold - 示例

以下是一个简单的示例,简单说明了此效果的用法-

<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>

这将产生以下输出-

无涯教程网

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

技术与商业案例解读 -〔徐飞〕

Flutter核心技术与实战 -〔陈航〕

JavaScript核心原理解析 -〔周爱民〕

动态规划面试宝典 -〔卢誉声〕

Spark核心原理与实战 -〔王磊〕

李智慧 · 高并发架构实战课 -〔李智慧〕

Vue 3 企业级项目实战课 -〔杨文坚〕

B端体验设计入门课 -〔林远宏(汤圆)〕

结构思考力 · 透过结构看表达 -〔李忠秋〕

好记忆不如烂笔头。留下您的足迹吧 :)