-
-
Save a1GoXplorer/9aa5e7fb6cb006b83c2b 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.1.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body id="body"> | |
<script id="jsbin-javascript"> | |
$(function() { | |
//converted to a DOM element | |
var gameBoard = $("<div></div>"); | |
$("#body").append(gameBoard); | |
var interval = 1500 | |
var generateRand = function () { | |
interval = interval - 5; | |
var rand = Math.floor(Math.random() * 26) + 97 | |
var char = String.fromCharCode(rand); | |
gameBoard.append("<span class='" + char +"'>" + char + "</span>"); | |
//console.log(interval); | |
setTimeout(generateRand, interval); | |
}; | |
$("#body").keypress(function(e){ | |
var charPressed = String.fromCharCode(e.which); | |
gameBoard.find("."+charPressed + ":first-child").remove() | |
console.log(charPressed); | |
}) | |
generateRand(); | |
}); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//code.jquery.com/jquery-1.11.1.min.js"><\/script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body id="body"> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">$(function() { | |
//converted to a DOM element | |
var gameBoard = $("<div></div>"); | |
$("#body").append(gameBoard); | |
var interval = 1500 | |
var generateRand = function () { | |
interval = interval - 5; | |
var rand = Math.floor(Math.random() * 26) + 97 | |
var char = String.fromCharCode(rand); | |
gameBoard.append("<span class='" + char +"'>" + char + "</span>"); | |
//console.log(interval); | |
setTimeout(generateRand, interval); | |
}; | |
$("#body").keypress(function(e){ | |
var charPressed = String.fromCharCode(e.which); | |
gameBoard.find("."+charPressed + ":first-child").remove() | |
console.log(charPressed); | |
}) | |
generateRand(); | |
});</script></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
$(function() { | |
//converted to a DOM element | |
var gameBoard = $("<div></div>"); | |
$("#body").append(gameBoard); | |
var interval = 1500 | |
var generateRand = function () { | |
interval = interval - 5; | |
var rand = Math.floor(Math.random() * 26) + 97 | |
var char = String.fromCharCode(rand); | |
gameBoard.append("<span class='" + char +"'>" + char + "</span>"); | |
//console.log(interval); | |
setTimeout(generateRand, interval); | |
}; | |
$("#body").keypress(function(e){ | |
var charPressed = String.fromCharCode(e.which); | |
gameBoard.find("."+charPressed + ":first-child").remove() | |
console.log(charPressed); | |
}) | |
generateRand(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment