目录

Bounce

描述 (Description)

Bounce效果可以与effect()方法一起使用。 这会使元素垂直或水平多次反弹。

语法 (Syntax)

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

<i>selector</i>.effect( "bounce", {arguments}, speed );

参数 (Parameters)

以下是所有论点的描述 -

  • direction - 效果的方向。 可以是“向上”,“向下”,“向左”,“向右”。 默认为“up”。

  • distance - 反弹距离。 默认值为20

  • mode:效果模式。 可以是“显示”,“隐藏”或“效果”。 默认为“效果”。

  • times - 反弹的时间。 默认值为5。

例子 (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() {
            $("#button").click(function(){
               $(".target").effect( "bounce", {times:3}, 300 );
            });
         });
      </script>
      <style>
         p {background-color:#bca; width:200px; border:1px solid green;}
         div{ width:100px; height:100px; background:red;}
      </style>
   </head>
   <body>
      <p>Click the button</p>
      <button id = "button"> Bounce </button>
      <div class = "target">
      </div>
   </body>
</html>

这将产生以下结果 -

新页面打开
↑回到顶部↑
WIKI教程 @2018