jQuery.fx.off


jQuery.fx.off返回: Boolean

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

  • 添加的版本: 1.3jQuery.fx.off

当这个属性设置为true的时候,调用时所有动画方法将立即设置元素为他们的最终状态,而不是显示效果。有时候确实有必要这样做:

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

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

例子:

切换开启和关闭动画。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!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.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: