返回值:BooleanjQuery.fx.off

禁用所有动画。

把这个属性设置为 true 后,所有动画方法会立即停止特效,并把元素设置成动画的最终状态。有时候确实有必要这样做,比如:

  • jQuery 用在资源较少的设备上。
  • 用户由于动画效果而遇到了可访问性问题。(详见如下文章 Turn Off Animation 来获得更多信息)。

当把这个属性设成 false 之后,可以重新开启所有动画。

示例:

切换开启和关闭动画。

<!DOCTYPE html>
<html>
<head>
<style>
    div { width:50px; height:30px; margin:5px; float:left;
          background:green; }
    </style>
<script src="jquery.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>

演示: