Created
January 26, 2012 21:02
-
-
Save scopevale/1685090 to your computer and use it in GitHub Desktop.
jsFiddle demo - setTimeout()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id="button1"> | |
show an alert box after 4 seconds | |
</button><br> | |
<button id="button2">Cancel</button><br/> | |
<button id="button3">Click Me</button><br/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
function slowAlert() { | |
alert("That was really slow!"); | |
} | |
function delayedAlert() { | |
timeoutID = window.setTimeout(slowAlert, 4000); | |
} | |
function clearAlert() { | |
window.clearTimeout(timeoutID); | |
} | |
function customAlert(event) { | |
window.setTimeout(function() { | |
alert(event.data.foo); | |
}, 4000); | |
} | |
$('#button1').bind('click', delayedAlert); | |
$('#button2').bind('click', clearAlert); | |
$("#button3").bind("click", { | |
foo: "bar" | |
}, customAlert); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: jsFiddle/Gist demo - setTimeout | |
description: jsFiddle demo hosted on Gist | |
authors: | |
- Gary Smith | |
title: | |
- JS Fiddle - jsFiddle/Gist integration demo - setTimeout | |
resources: | |
- /js/empty.js | |
normalize_css: yes | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsfiddle.net/gh/gist/jquery/edge/1685090/