jQuery.fx.off() trong jQuery



Miêu tả

Phương thức jQuery.fx.off() trong jQuery sẽ vô hiệu hóa toàn bộ tất cả hiệu ứng.

Cú pháp

Sau đây là cú pháp cho jQuery.fx.off() trong jQuery:

jQuery.fx.off = [true | false ] ;

Tham số

Dưới đây miêu tả chi tiết về các tham số được sử dụng trong phương thức jQuery.fx.off() trong jQuery:

  • Boolean − Nếu là false thì sẽ kích hoạt tất cả hiệu ứng, nếu là true thì vô hiệu hóa.

Quảng cáo

Ví dụ

Sau đây là ví dụ đơn giản minh họa cách sử dụng của phương thức jQuery.fx.off() 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" language="javascript">
         $(document).ready(function() {

            $("#enable").click(function(){
               jQuery.fx.off = false;
            });

            $("#disable").click(function(){
               jQuery.fx.off = true;
            });

            $("#go").click(function(){
               $(".target").animate({left: '+=200px'}, 2000);
            });

            $("#back").click(function(){
               $(".target").animate({left: '-=200px'}, 200);
            });
         });
      </script>
		
      <style>
         p {background-color:#bca; width:350px; border:1px solid green;}   
         div{position: absolute; left: 50px; top:300px;}
      </style>
		
   </head>
		
   <body>

      <p>Click enable or disable and then go or back button:</p>
		
      <button id="enable"> Enable</button>
      <button id="disable"> Disable </button>
      <button id="go"> GO</button>
      <button id="back"> BACK </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