Hiệu ứng Drop trong jQuery



Miêu tả

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

Cú pháp

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

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

Tham số

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

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

  • mode − Chế độ của hiệu ứng, có thể là "show", "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 Drop 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( "drop", {direction: "up"}, 1000 );
            });

            $("#show").click(function(){
               $(".target").show( "drop", {direction: "down"}, 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