Skip to content

Instantly share code, notes, and snippets.

@scopevale
Created January 26, 2012 21:02
Show Gist options
  • Save scopevale/1685090 to your computer and use it in GitHub Desktop.
Save scopevale/1685090 to your computer and use it in GitHub Desktop.
jsFiddle demo - setTimeout()
<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/>
$(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);
});
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
...
@scopevale
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment