<div>
<p>Open console and press both buttons repeatedly, you will notice that the left one doesn't execute until the animation is finished, the second one is executed although the aniamtion is not ended</p>
<button id="limit">Toggle waiting until finish</button>
<button id="no-limit">Toggle without waiting</button>
<br>
<div class="gray-border">
<span>Toggling Div<span>
</div>
<div>
// To check the functionality of the buttons you should press them repeatedly and check the console.
// Button with id='#limit' doesn't execute the toggle if the div is still being animated
$('#no-limit').click(function () {
$('.gray-border').fadeToggle(1000);
console.log('Without Limit');
});
$('#limit').click(function () {
if (!$('.gray-border').is(':animated')) { // If the div is not being animated
$('.gray-border').fadeToggle(1000);
console.log('With Limit');
}
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.