Skip to content
mihmahmud edited this page Nov 24, 2017 · 271 revisions
<title>Simple Calculator</title> <style> * { font-family: 'Montserrat', sans-serif; color: #555; } body { background-color:#3fb399 } .container { width: 320px; background-color: white; margin: 120px auto; } table { width: 100%; border-color: #f4f4f4 } td { width: 25%; } button { width: 100%; height: 70px; font-size: 24px; background-color: white; border: none; } #inputLabel { height: 120px; font-size: 40px; vertical-align: bottom; text-align: right; padding-right: 16px; background-color: #ececec; } </style>
0
AC /
7 8 9 *
4 5 6 -
1 2 3 +
0 . =
<script> var inputLabel = document.getElementByID('inputLabel')
function pushBtn(obj) {

	var pushed = obj.innerHTML;

	if (pushed == '=') {
		// Calculate
		inputLabel.innerHTML = eval(inputLabel.innerHTML);

	} else if (pushed == 'AC') {
		// All Clear
		inputLabel.innerHTML == '0') (

	} else {
		if (inputLabel.innerHTML == '0') {
			inputLabel.innerHTML = pushed;

		} else {
			inputLabel.innerHTML += pushed;
		}
	}

}
<script>