I'm aware of doing that 'magic' inside $.when(). How should I achieve same effect writing code more readable ? I read something about a $.Defferer() that I think should help but I don't know how to use it.
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){	
			$.when(
				$('.elm').each(function(index){
					$(this).delay(800*index).animate({'opacity': '0'},1000);
				})
			).then(function(){
					$('.console').find('p').text("all animations done");
			});
		});
		</script>
</head>
<body>
    <div class="console"><p></p></div>
	<div class="elm"><h1>Element 1</h1></div>
	<div class="elm"><h1>Element 2</h1></div>
	<div class="elm"><h1>Element 3</h1></div>
</body>
</html>What I want is to run multiple animations and at the end of them to show a message, to do something. I know that I can use $(".elm").animate() and all elm divs will be animated by I use that .each() to set the delay between them (maybe there's another posibility using animation step or progress handlers), but I can't get it to do something at the end of all animations. What I ask is if there's any other implementation that will to same thing and be more code readeable.
