Hello Readers,
We use the jquery property jQuery.fx.off or $.fx.off (globally disable all animations). By default its value is false, when we set this property to true, disables all the animation in jquery.
So, instead of displaying an effect it will immediately set elements to their final state.
Syntax :
jQuery.fx.off = true|false;
Parameter:
true : Specifies that animations should be disabled.
false : it is default value which specifies that animations should be enabled.
Below is the Code Example :
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/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>
<button id="disable">jQuery.fx.off = true ( Disable )</button>
<button id="enable">jQuery.fx.off = false ( Enable )</button>
<br><br>
<button id="toggle">Toggle animation</button>
<div style="background:#98bf21;height:100px;width:100px;margin:50px;"></div>
</body>
</html>
In the above, code example we use the toggle method so when we press toggle animation button, we toggle between hiding and showing the div with a slow animation.
We also use the "Enable" or "disable" button to turn the animations on or off.
0 Comment(s)