jQuery jQuery.fx.off 属性
实例
打开和关闭动画:
<!DOCTYPE html><html><head><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><script>$(document).ready(function(){$("#disable").click(function(){jQuery.fx.off = true;});$("#enable").click(function(){jQuery.fx.off = false;});$("#toggle").click(function(){$("div").toggle("slow");});});</script></head><body><p>When the "Toggle animation" button is pressed, we toggle between hiding and showing the div with a slow animation. Press "Enable" or "Disable" to turn animations on and off.</p><button id="disable">jQuery.fx.off = true ( 不可用 )</button><button id="enable">jQuery.fx.off = false ( 可用 )</button><br><br><button id="toggle">切换动画</button><div style="background:#98bf21;height:100px;width:100px;margin:50px;"></div></body></html>
定义与用法
jQuery.fx.off 属性用于全局禁用/启用所有动画。
默认值为 false,这允许动画正常运行。设置为 true 时,将禁用所有动画方法,这将立即将元素设置为其最终状态,而不是显示效果。
提示: 要简化代码, 可用使用 $.fx.off 代替 jQuery.fx.off。
语法
jQuery.fx.off = true|false;
| 参数 | 描述 |
|---|---|
| true | 指定应禁用动画 |
| false | 默认值。指定应启用动画 |