Hiệu ứng Fold trong jQuery



Miêu tả

Hiệu ứng Fold có thể được sử dụng với show/hide/toggle. Nó Fold phần tử như một phần của tờ giấy.

Cú pháp

Sau đây là cú pháp để sử dụng hiệu ứng Fold trong jQuery:

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

Tham số

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

  • horizFirst − Có hay không để gấp theo chiều ngang trước. Có thể là true hoặc false, mặc định là false.

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

  • size − Kích thước để bị gấp, mặc định là 15.

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 Fold 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( "fold", {horizFirst: true }, 2000 );
            });

            $("#show").click(function(){
               $(".target").show( "fold", {horizFirst: true}, 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>

Nó sẽ cho kết quả:

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


hieu_ung_trong_jquery.jsp