Advertisement
mosaid

calc

Jun 8th, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.16 KB | None | 0 0
  1. <html>
  2.     <script src="http://code.jquery.com/jquery-1.12.0.js"></script>
  3.     <style>
  4.         button {
  5.             width: 300px;
  6.             height: 100px;
  7.             font-size:3em;
  8.             color:green;
  9.         }
  10.         div {
  11.             height: 200px;
  12.             background-color:beige;
  13.             font-size:2em;
  14.         }
  15.        
  16.     </style>
  17.     <audio id="audio" src="http://www.soundjay.com/button/beep-07.wav" autostart="false" ></audio>
  18.     <script>
  19.         function clr(){
  20.             var div1 = document.getElementById('div1');
  21.             var div2 = document.getElementById('div2');
  22.             div1.innerHTML ="";
  23.             div2.innerHTML ="";
  24.         }
  25.         function add(obj){
  26.             var div1 = document.getElementById('div1');
  27.             var div2 = document.getElementById('div2');
  28.             div1.innerHTML +=obj.id + " + ";
  29.             var x =  Number(div2.innerHTML) +  Number(obj.id);
  30.             div2.innerHTML=x.toString();
  31.             var sound = document.getElementById("audio");
  32.           sound.play();
  33.         }
  34.     </script>
  35.     <div id="div1"></div><br>
  36.     <div id="div2"></div><br>
  37.     <br>
  38.     <button id="0.25" onclick=add(this)>0.25</button>
  39.     <button id="0.5" onclick=add(this)>0.5</button>
  40.     <button id="0.75" onclick=add(this)>0.75</button>
  41.     <button id="1" onclick=add(this)>1</button>
  42.     <button id="1" onclick=clr()>clear</button>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement