jQuery.fx.off

jQuery.fx.off 官网原E文: Boolean

描述: 全局禁用所有动画。

  • version added: 1.3jQuery.fx.off

当这个属性设置为true的时候,调用时所有动画方法将立即设置元素为他们的最终状态,而不是显示效果。这可能令人满意的几个原因:

  • jQuery是被用在低资源设备。
  • 动画使用户遇到可访问性问题(查看这篇文章获得更多信息 Turn Off Animation)。

动画可以通过设置这个属性为false重新打开。

Example:

Toggle animation on and off

<!DOCTYPE html>
<html>
<head>
  <style>
    div { width:50px; height:30px; margin:5px; float:left;
          background:green; }
    </style>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <p><input type="button" value="Run"/> <button>Toggle fx</button></p>
<div></div>
<script>
var toggleFx = function() {
  $.fx.off = !$.fx.off;
};
toggleFx();

$("button").click(toggleFx)

$("input").click(function(){
  $("div").toggle("slow");
});
  </script>

</body>
</html>

Demo:

jQuery 1.6 API 中文版Clove整理、修订