jQuery 中的 Slide方法函数

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

幻灯片效果可以与show/hide/toggle一起使用。这会将元素滑出视口。

Slide - 语法

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

这是所有参数的描述-

  • direction  - 效果的方向。可以是"左(left)","右(right)","上(up)","下(down)"。默认值:left。

  • distance   - 效果的距离。根据方向选项设置为元素的高度或宽度。

    无涯教程网

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

Slide - 示例

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

<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( "slide", { direction: "down"  }, 2000 );
            });

            $("#show").click(function(){
               $(".target").show( "slide", {direction: "up" }, 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>

这将产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/jquery/effect-slide.html

来源:LearnFk无涯教程网

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

技术教程推荐

MySQL实战45讲 -〔林晓斌〕

重学前端 -〔程劭非(winter)〕

面试现场 -〔白海飞〕

Netty源码剖析与实战 -〔傅健〕

正则表达式入门课 -〔涂伟忠〕

如何读懂一首诗 -〔王天博〕

数据分析思维课 -〔郭炜〕

徐昊 · TDD项目实战70讲 -〔徐昊〕

结构思考力 · 透过结构看问题解决 -〔李忠秋〕

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