Created
July 9, 2014 05:46
-
-
Save java-MagicWang/87413336c61c4b23ef36 to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
</head> | |
<body> | |
<div> | |
<span id="timer"></span> | |
<br/> | |
<div> | |
<input id="send" type="button" value="send" onclick="javascript:sendEmail();"/> | |
<input type="button" value="cancel" onclick="javascript:cancel();"/> | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains 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
var count=4; | |
var counter;//1000 will run it every 1 second | |
function sendEmail() { | |
counter = setInterval(timer, 1000); | |
$("#send").attr("disabled","disabled"); | |
} | |
function cancel() { | |
clearInterval(counter); | |
$("#timer").html("Email has bean canceled!"); | |
$("#send").removeAttr("disabled"); | |
count=4; | |
} | |
function timer() { | |
count=count-1; | |
if (count <= 0) { | |
clearInterval(counter); | |
//counter ended, do something here | |
count=4 | |
$("#timer").hide(); | |
$("#send").removeAttr("disabled"); | |
return; | |
}else { | |
$("#timer").show(); | |
$("#timer").html("sending... "+count+" secs"); | |
} | |
//Do code for showing the number of seconds here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment