D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
zischwartz
Full window
Github gist
ScriptEd Unit 7 Project: Hi- Lo // source http://jsbin.com/lejewepeyo
<!DOCTYPE html> <html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="css/highlow.css" rel="stylesheet" type="text/css" /> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="js/guts.js"></script> <script src="js/highlow.js"></script> <title>ScriptEd Unit 7 Project: Hi- Lo</title> <style id="jsbin-css"> .container { max-width: 600px; } #check-btn { margin-top: 20px; } #generate-btn { margin: 20px; } </style> </head> <body> <div class="container"> <h1>ScriptEd Unit 7 Project: Hi-Lo</h1> <hr/> <div class="text-center"> <button type="submit" id="generate-btn" class="btn btn-primary btn-lg">Generate random number</button> <input type="text" class="form-control input-lg " id="guess" placeholder="Guess a number between 1 and 10"> <button type="submit" id="check-btn" class="btn btn-success btn-lg">Check</button> <br/> <br/> <div class="alert text-left" role="alert" id="correct">.</div> </div> </div> <script id="jsbin-javascript"> var guess_count = 0; function generateRandomNumber() { // YOUR CODE GOES HERE return Math.ceil(Math.random()*10000); } function checkGuess(guess, generatedRandomNumber) { guess_count++; // guess_count = guess_count + 1; // console.log(guess_count); if (guess === generatedRandomNumber){ alert('win'); $('#generate-btn').show(); $("#guess").val(""); } // else if (guess_count ==3) { // alert('you loser!!'); // } // YOUR CODE GOES HERE //INCLUDE THESE TWO LINES IN YOUR WIN CONDITION } //Don't edit. $(document).ready(function(){ var randomNum = 0; $('#generate-btn').on("click", function(){ randomNum = generateRandomNumber(); console.log(randomNum); $('#generate-btn').hide(); }); $('#check-btn').on("click", function(){ var guess = parseInt($('#guess').val()); checkGuess(guess, randomNum); }); }); </script> <script id="jsbin-source-css" type="text/css">.container { max-width: 600px; } #check-btn { margin-top: 20px; } #generate-btn { margin: 20px; }</script> <script id="jsbin-source-javascript" type="text/javascript">var guess_count = 0; function generateRandomNumber() { // YOUR CODE GOES HERE return Math.ceil(Math.random()*10000); } function checkGuess(guess, generatedRandomNumber) { guess_count++; // guess_count = guess_count + 1; // console.log(guess_count); if (guess === generatedRandomNumber){ alert('win'); $('#generate-btn').show(); $("#guess").val(""); } // else if (guess_count ==3) { // alert('you loser!!'); // } // YOUR CODE GOES HERE //INCLUDE THESE TWO LINES IN YOUR WIN CONDITION } //Don't edit. $(document).ready(function(){ var randomNum = 0; $('#generate-btn').on("click", function(){ randomNum = generateRandomNumber(); console.log(randomNum); $('#generate-btn').hide(); }); $('#check-btn').on("click", function(){ var guess = parseInt($('#guess').val()); checkGuess(guess, randomNum); }); }); </script></body> </html>
https://code.jquery.com/jquery-1.9.1.min.js