加载中...

jQuery.fx.off


概述    jQuery.fx.off

返回值:Boolean

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

  • V : 1.3jQuery.fx.off

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

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

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

示例

切换开启和关闭动画。

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. div { width:50px; height:30px; margin:5px; float:left;
  6. background:green; }
  7. </style>
  8. <script src="http://code.jquery.com/jquery-latest.js"></script>
  9. </head>
  10. <body>
  11. <p><input type="button" value="Run"/> <button>Toggle fx</button></p>
  12. <div></div>
  13. <script>
  14. var toggleFx = function() {
  15. $.fx.off = !$.fx.off;
  16. };
  17. toggleFx();
  18. $("button").click(toggleFx)
  19. $("input").click(function(){
  20. $("div").toggle("slow");
  21. });
  22. </script>
  23. </body>
  24. </html>

运行一下


还没有评论.