Hiệu ứng Blind trong jQuery



Miêu tả

Hiệu ứng Blind có thể được sử dụng với show/hide/toggle. Nó Blind away phần tử hoặc hiển thị nó bằng blind in.

Cú pháp

Sau đây là cú pháp cho hiệu ứng blind trong jQuery:

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

Tham số

Chi tiết tham số được sử dụng để tạo hiệu ứng blind trong jQuery:

  • direction − Phương hướng của hiệu ứng, có thể là "vertical" hoặc "horizontal". Mặc định là vertical.

  • mode − Chế độ của hiệu ứng, có thể là "show" hoặc "hide". Mặc định là hide.

Quảng cáo

Ví dụ

Sau đây là ví dụ đơn giản minh họa cách sử dụng của hiệu ứng blind trong jQuery:

<html>
   <head>
      <title>The jQuery Example</title>
      <script type="text/javascript" src="http://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>

Nó sẽ cho kết quả:

Các bài học jQuery khác tại VietJack:


hieu_ung_trong_jquery.jsp