kuruku

MathTest

Oct 1st, 2014
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.35 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5.         <title>Simple Calculator</title>
  6.         <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
  7.         <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.js"></script>
  8.         <script src="jquery.paulund_modal_box.js"></script>
  9.  
  10.  
  11.     </head>
  12.     <body>
  13.         <div class="equetion">
  14.             <div class="first"></div>
  15.             <div class="sign">+</div>
  16.             <div class="second"></div>
  17.             <div class="result22"></div>
  18.         </div>
  19.  
  20.  
  21.         <div class="resultWr">=?</div>
  22.         <div class="resultWr1"></div>
  23.         <div class="result"></div>
  24.         <div class="dialog"></div>
  25.  
  26.  
  27.  
  28.         <script>
  29.             var $num = Math.floor(Math.random() * 20) + 1;
  30.             var $num2 = Math.floor(Math.random() * 20) + 1;
  31.             var $result = $num + $num2;
  32.             var $resultWr = $num + $num2 - 1;
  33.             var $resultWr1 = $num + $num2 + 1;
  34.  
  35.  
  36.             $("body").css("background", "#eee")
  37.  
  38.               // Add containers to the DOM
  39.             $(".first").css({"background": "#eee", "width": "50px", "height": "50px", "font-size": "40px", "text-align": "center", "display": "inline-block"}).text($num);
  40.             $(".second").css({"background": "#eee", "width": "50px", "height": "50px", "font-size": "40px", "text-align": "center", "display": "inline-block"}).text($num2);
  41.             $(".sign").css({"background": "#eee", "width": "50px", "height": "50px", "font-size": "40px", "text-align": "center", "display": "inline-block"}).text("+");
  42.             $(".result22").css({"background": "#eee", "width": "50px", "height": "50px", "font-size": "40px", "text-align": "center", "display": "inline-block"}).text("= ?");
  43.             $(".result").css({"background": "#eee", "width": "50px", "height": "50px", "font-size": "40px", "text-align": "center", "position": "absolute", "left": "200px", "top": "200px", "border": "2px solid green", "border-radius": "50%"}).text($result);
  44.             $(".resultWr").css({"background": "#eee", "width": "50px", "height": "50px", "font-size": "40px", "text-align": "center", "position": "absolute", "left": "100px", "top": "200px", "border": "2px solid green", "border-radius": "50%"}).text($resultWr);
  45.             $(".resultWr1").css({"background": "#eee", "width": "50px", "height": "50px", "font-size": "40px", "text-align": "center", "position": "absolute", "left": "300px", "top": "200px", "border": "2px solid green", "border-radius": "50%"}).text($resultWr1);
  46.  
  47.             $("div").hover(
  48.                     function() {
  49.                         $(this).css("background", "#eee");
  50.                     },
  51.                     function() {
  52.                         $(this).css("background", "#eee");
  53.                     }
  54.             );
  55.             $("div").css({"background": "#eee", "width": "50px", "height": "50px", "font-size": "40px", "text-align": "center"});
  56.             $(".equetion").css({"width": "400px", "text-align": "center", "position": "absolute", "left": "80px", "top": "60px"});
  57.  
  58.             $(".result").click(function() {
  59.                 $(".result").css("background", "green");
  60.                 var $input = $('<span/>').appendTo("body");
  61.                 $("span").css({"background": "green", "width": "200px", "text-align": "center", "position": "absolute", "left": "100px", "top": "280px"}).text("CORRECT");
  62.  
  63.                 setTimeout(function() {
  64.                     $('body').slideUp('slow', window.location.reload());
  65.                 }, 5000);
  66.             });
  67.  
  68.             $(".resultWr1").click(function() {
  69.                 $(".resultWr1").css("background", "red");
  70.                 var $input = $('<span/>').appendTo("body");
  71.                 $("span").css({"background": "red", "width": "200px", "text-align": "center", "position": "absolute", "left": "100px", "top": "280px"}).text("WRONG");
  72.             });
  73.  
  74.             $(".resultWr").click(function() {
  75.                 $(".resultWr").css("background", "red");
  76.                 var $input = $('<span/>').appendTo("body");
  77.                 $("span").css({"background": "red", "width": "200px", "text-align": "center", "position": "absolute", "left": "100px", "top": "280px"}).text("WRONG");
  78.             });
  79.         </script>
  80.     </body>
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment