Skip to content

Instantly share code, notes, and snippets.

@SaraJo
Created March 13, 2020 20:33
Show Gist options
  • Save SaraJo/a7c26e12004ba2a42c3a4796320b20bc to your computer and use it in GitHub Desktop.
Save SaraJo/a7c26e12004ba2a42c3a4796320b20bc to your computer and use it in GitHub Desktop.
Baby Calculator
<html>
<head>
<style>
button{
width: 50px;
height: 50px;
font-weight: bold;
}
input{
border: 1px solid green;
width: 100px;
}
div{
border: 1px solid grey;
width: 400px;
}
</style>
<script>
function add(){
var first = document.getElementById("first-int").value
, second = document.getElementById("second-int").value;
window.alert(parseInt(first) + parseInt(second));
}
</script>
</head>
<div>
<p>
<label for="first-int">first number:</label>
<input type="text" id="first-int" />
<label for="second-int">second number:</label>
<input type="text" id="second-int" />
</p>
<p>
<button id="add" onclick="add()">+</button>
<button id="subtract">-</button>
<button id="multiply">*</button>
<button id="divide">/</button>
</p>
</div>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment