无涯教程-jQuery - Clip方法函数

95 阅读1分钟

剪辑效果可与show/hide/toggle一起使用。这将在垂直或水平方向上将元素剪裁为ON或OFF。

Clip - 语法

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

下面是对所有参数-的描述

  • direction - 方向。可以是“垂直(vertical)”或“水平(horizontal)”。默认为垂直(vertical)。

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

Clip - 示例

下面是一个简单的示例,一个简单的示例显示了此效果-的用法

<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( "clip", {direction: "horizontal"}, 1000 );
            });

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

这将产生以下输出-

参考链接

www.learnfk.com/jquery/effe…