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

Blind

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

描述 (Description)

Blind效果可以与show/hide/toggle一起使用。 这会使元素失明或通过使其隐藏来显示它。

语法 (Syntax)

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

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

参数 (Parameters)

以下是所有论点的描述 -

  • direction - 效果的方向。 可以是“垂直”或“水平”。 默认为垂直。

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

例子 (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( "blind", {direction: "horizontal"}, 1000 );
            });
            $("#show").click(function(){
               $(".target").show( "blind", {direction: "horizontal"}, 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>