Skip to content

Instantly share code, notes, and snippets.

@cflove
Created February 28, 2014 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cflove/9263591 to your computer and use it in GitHub Desktop.
Save cflove/9263591 to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<style type="text/css" media="screen">
.box {background-color: red; width: 80px; height: 80px; display: inline-block;}
</style>
</head>
<body>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<script type="text/javascript">
// function sayHello() {
// alert("hello")
// }
// setTimeout(sayHello, 2000)
// =====================================================================
// var greeting
// function sayHello() {
// var greeting = "Hello "
// alert("function said : " + greeting)
// }
// setTimeout(sayHello, 2000)
// alert("page said : " + greeting)
// =====================================================================
// var setValue = function() {
// var states = $.Deferred();
// function sayHello() {
// // states.resolve();
// states.reject();
// var greeting = "Hello"
// alert("function said : " + greeting)
// }
// setTimeout(sayHello, 4000)
// return states.promise()
// }
// var x = setValue()
// x.done(function(){
// alert("Function Triggered")
// })
// x.fail(function() {
// alert("Failed!")
// } )
// =====================================================================
// $('.box').each(function(index, val) {
// // alert(index)
// $(this).delay(1000*index).fadeOut('slow')
// }).promise().done(function(){
// alert("All Done")
// });
// =====================================================================
// fadeBoxes = function() {
// return $('.box').each(function(index, val) {
// $(this).delay(1000*index).fadeOut('slow')
// })
// }
// ShowBoxes = function () {
// return $('.box').each(function(index, val) {
// $(this).delay(1000*index).fadeIn('slow')
// })
// }
// fadeBoxes().promise().done( ShowBoxes )
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment