jQuery.fx.off
分类:效果 > 自定义效果 | 属性 > 全局jQuery对象的属性
返回: Boolean
jQuery.fx.off
描述:全局性地禁用所有动画。
加入于: 1.3
jQuery.fx.off当这个属性被设置为true,所有的动画方法会立即把元素设置到它们的最终状态,而不是显示效果。可能出于下面两种原因而想要这个设置:
- 在一个资源不足的设备上使用jQuery。
- 用户在用动画时遇到了可访问性问题。
通过把该属性设置为false,可以重新打开动画。
示例
打开或关闭动画。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.fx.off demo</title>
<style>
div {
width: 50px;
height: 30px;
margin: 5px;
float: left;
background: green;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<input type="button" value="Run">
<button>Toggle fx</button>
<div></div>
<script>
var toggleFx = function() {
$.fx.off = !$.fx.off;
};
toggleFx();
$( "button" ).click( toggleFx );
$( "input" ).click(function() {
$( "div" ).toggle( "slow" );
});
</script>
</body>
</html>
演示结果