Code of Calculator javascript - knowledgecityfree
Complete code for calculator using JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
<style>
body{
padding: 0;
margin: 0;
background-color: aquamarine;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.main{
margin-top: 150px;
background-color: rgb(103, 107, 107);
padding: 15px;
}
#row{
border: none;
outline: none;
box-shadow: 0 0 2px grey;
height: 40px;
width: 208px;
font-size: 20px;
text-align: right;
}
.row1{
margin-top: 10px;
}
.row1 input{
width: 50px;
height: 30px;
}
</style>
</head>
<body>
<div class="main">
<form action="">
<div class="text">
<input type="text" name="display" id="row">
</div>
<div class="row1">
<input type="button" value="Ac" onclick="display.value = '' ">
<input type="button" value="del" onclick="display.value = display.value.toString().slice(0, -1) ">
<input type="button" value="sqrt" onclick="display.value += 'Math.sqrt()' ">
<input type="button" value="/" onclick="display.value = '/' ">
</div>
<div class="row1">
<input type="button" value="7" onclick="display.value += '7' ">
<input type="button" value="8" onclick="display.value += '8' ">
<input type="button" value="9" onclick="display.value += '9' ">
<input type="button" value="*" onclick="display.value += '*' ">
</div>
<div class="row1">
<input type="button" value="4" onclick="display.value += '4' ">
<input type="button" value="5" onclick="display.value += '5' ">
<input type="button" value="6" onclick="display.value += '6' ">
<input type="button" value="+" onclick="display.value += '+' ">
</div>
<div class="row1">
<input type="button" value="1" onclick="display.value += '1' ">
<input type="button" value="2" onclick="display.value += '2' ">
<input type="button" value="3" onclick="display.value += '3' ">
<input type="button" value="-" onclick="display.value += '-' ">
</div>
<div class="row1">
<input type="button" value="0" onclick="display.value += '0' ">
<input type="button" value="00" onclick="display.value+= '00' ">
<input type="button" value="." onclick="display.value += '.' ">
<input type="button" value="=" onclick="display.value = eval(display.value) ">
</div>
</form>
</div>
</body>
</html>
Post a Comment