当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JQuery jQuery.fx.off用法及代码示例


用法
jQuery.fx.off => Boolean

说明:全局禁用所有动画。

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

当此属性设置为 true 时,所有动画方法都会在调用时立即将元素设置为其最终状态,而不是显示效果。出于以下几个原因,这可能是可取的:

  • jQuery 正在low-resource 设备上使用。
  • 用户遇到动画的可访问性问题。

通过将属性设置为 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-3.5.0.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>

演示:

相关用法


注:本文由纯净天空筛选整理自jquery.com大神的英文原创作品 jQuery.fx.off。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。