Hiệu ứng Explode trong jQuery



Miêu tả

Hiệu ứng Explode có thể được sử dụng với show/hide/toggle. Nó Explode phần tử thành nhiều phần.

Cú pháp

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

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

Tham số

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

  • pieces − Số phần để bị explode hoặc implode.

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

Ví dụ

Sau đây là ví dụ đơn giản minh họa cách sử dụng của hiệu ứng Explode 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( "explode", {pieces: 16 }, 2000 );
            });

            $("#show").click(function(){
               $(".target").show( "explode", {pieces: 16}, 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>
Quảng cáo

Nó sẽ cho kết quả:

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


hieu_ung_trong_jquery.jsp