USA +1 7065 38-39-40 UK +44 754-373-15-03 CY +357-96-38-39-40 WhatsApp Messenger Skype Send message info@24glo.com
<div id="container">
<div id="menu">
<input id="max" type="text" placeholder="Max" />
<button id="gamebtn">New Game</button>
<span id="guess_count"></span>
</div>
<div id="guesses">
</div>
<div id="footer">
<input id="aGuess" type="text" placeholder="guess" />
<button id="guessbtn">Guess</button>
</div>
</div>
<script type="text/javascript" src="jquery-2.1.1.min.js"></script>
<script>
$(function(){
var num;
var guesses;
var max_el = $('#max'),
gamebtn = $('#gamebtn'),
count_el = $('#guess_count'),
guess_el = $('#aGuess'),
guessbtn = $('#guessbtn'),
guesses_el = $('#guesses'),
footer = $('#footer');
footer.hide();
gamebtn.on('click', function(){
num = getRandomInt(1, parseInt(max_el.val()));
guesses = 0;
guesses_el.empty();
footer.show();
updateCount();
});
guessbtn.on('click', function(){
var myGuess = parseInt(guess_el.val());
guesses++;
updateCount();
if(myGuess == num){
guesses_el.append("<p>it took you " + guesses + " guesses</p>");
footer.hide();
} else if( myGuess > num ) {
guesses_el.append("<p>lower (" + myGuess + ")</p>");
} else {
guesses_el.append("<p>higher (" + myGuess + ")</p>");
}
guess_el.val("");
guess_el.focus();
});
function updateCount(){
count_el.text(guesses + " guesses");
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
});
</script>
24glo.com
| ▲
| Contacts
Copyright © 24GLO LTD ® 2004-2024. All rights reserved.