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

Puff

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

描述 (Description)

Puff效果可以与show/hide/toggle一起使用。 这通过向上缩放元素并同时隐藏它来创建抽吸效果。

语法 (Syntax)

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

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

参数 (Parameters)

以下是所有论点的描述 -

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

  • percent - 要缩放的百分比。 默认值为150。

例子 (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( "puff", { }, 2000 );
            });
            $("#show").click(function(){
               $(".target").show( "puff", {percent:100}, 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>