Home >Web Front-end >JS Tutorial >Detailed explanation of jQuery.fx.off property and usage
jQuery.fx.offProperty is used to set or return whether to globally disable all animations.
If no value is set for this property, a Boolean value indicating whether the animation effect is globally disabled is returned.
If this property is set to true, all animations will be disabled globally. All executing animation queues will not be affected. Any animation queue that has not yet been executed will be completed as soon as it is executed, without any animation effect.
If this property is set to false, the animation effect will be enabled globally.
You can disable animation effects when you encounter the following situations.
You are using jQuery on a computer with low configuration.
Some users may be experiencing accessibility issues due to the animation effects.
This property belongs to the global jQuery object (can also be understood as static property).
Syntax
jQuery 1.3 adds this static attribute.
jQuery.fx.off
Return value
The return value of the jQuery.fx.off property is a Boolean type, returning a Boolean indicating whether the animation effect is globally disabled. value. Returns true if disabled, false otherwise.
By default, the return value of this property is false.
Example & Description
Please refer to the following HTML sample code:
e388a4556c0f65e1904146cc1a846bee
1ea9507f1220885b6d5513a610b33b4a
d08ce9ebd7632e0a07ebd5598b5e393c
0cba36f12cf561cef14ffa62bcdafa2c
f2337a0990b07148590e15ada5ffeac5CodePlayer16b28748ea4df4d9c2150843fecfba68
The jQuery sample code related to the jQuery.fx.off property is as follows:
$("#exec").click( function(){ var $myDiv = $("#myDiv"); // 在现有高度的基础上增加300px (如果原来是100px,增加后就是400px) $myDiv.animate( { height: "+=300px" }, 2000 ); $myDiv.animate( { width: "50%" }, 1000 ); $myDiv.animate( { width: "200px", height: "100px" }, 1000 ); } ); $("#switch").click( function(){ // 使用jQuery.fx.off或$.fx.off均可(如果变量$是jQuery在使用的话) if( $.fx.off ){ jQuery.fx.off = false; // 启用动画效果 this.value = "禁用动画效果"; }else{ $.fx.off = true; // 禁用动画效果 this.value = "启用动画效果"; } } );
The above is the detailed content of Detailed explanation of jQuery.fx.off property and usage. For more information, please follow other related articles on the PHP Chinese website!