Detailed explanation of jQuery.fx.off property and usage

巴扎黑
Release: 2017-06-30 13:15:50
Original
2172 people have browsed it

jQuery.fx.offPropertyis used to set or return whether to globally disable allanimations.

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 asstaticproperty).

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:

background-color: #eee;" >CodePlayer

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 = "启用动画效果"; } } );
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!