jQuery(document).ready(function($) {
jQuery(".btn-number").click(function() {
document.getElementById('calc-screen').value += this.value;
});
});
#calc-body,
#calc-screen,
.buttons-row {
display: block;
text-align: center;
margin-left: auto;
margin-right: auto;
line-height: 2;
}
#calc-body {
background-color: #8d9194;
border: 10px solid #697076;
border-radius: 55px;
width: 300px;
height: 400px;
padding: 50px 0px;
margin-top: 5%;
margin-bottom: 5%;
}
#calc-screen {
background-color: #697076;
border: 2px solid white;
border-radius: 25px;
color: white;
font-family: Anto, sans-serif;
font-size: 18px;
width: 250px;
}
#first-row {
margin-top: 20px;
}
.btn-clear,
.btn-plus-negative,
.btn-divide,
.btn-multiply,
.btn-number,
.btn-minus,
.btn-decimal {
background-color: #718598;
border: 2px solid white;
border-radius: 15px;
font-family: Anto, sans-serif;
font-size: 18px;
color: white;
width: 50px;
height: 50px;
margin-top: 10px;
margin-bottom: 10px;
}
.btn-equal {
background-color: #718598;
border: 2px solid white;
border-radius: 20px;
color: white;
font-family: Anto, sans-serif;
font-size: 18px;
width: 160px;
height: 50px;
margin-top: 10px;
margin-bottom: 10px;
}
input[class="btn-number"]:hover {
background-color: #9cafbd;
}
input[value="C"]:hover {
background-color: red;
}
input[value="="]:hover {
background-color: green;
}
#first-row,
#third-row,
#fifth-row {
background-color: rgba(255, 255, 255, 0.3);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="calc-body">
<input type="text" id="calc-screen" disabled="disabled">
<!-- end of #calc-screen -->
<row class="buttons-row" id="first-row">
<input type="button" class="btn-clear" value="C">
<input type="button" class="btn-plus-negative" value="+-">
<input type="button" class="btn-divide" value="%">
<input type="button" class="btn-multiply" value="x">
</row>
<!-- end of .buttons #second-row -->
<row class="buttons-row" id="second-row">
<input type="button" class="btn-number" value="7">
<input type="button" class="btn-number" value="8">
<input type="button" class="btn-number" value="9">
<input type="button" class="btn-minus" value="-">
</row>
<!-- end of .buttons #second-row -->
<row class="buttons-row" id="third-row">
<input type="button" class="btn-number" value="4">
<input type="button" class="btn-number" value="5">
<input type="button" class="btn-number" value="6">
<input type="button" class="btn-minus" value="+">
</row>
<!-- end of .buttons #third-row -->
<row class="buttons-row" id="fourth-row">
<input type="button" class="btn-number" value="1">
<input type="button" class="btn-number" value="2">
<input type="button" class="btn-number" value="3">
<input type="button" class="btn-decimal" value=".">
</row>
<!-- end of .buttons #fourth-row -->
<row class="buttons-row" id="fifth-row">
<input type="button" class="btn-number" id="zero" value="0">
<input type="button" class="btn-equal" value="=">
</row>
<!-- end of .buttons #fifth-row -->
</div>
<!-- end of calc-body -->
ありがとうございます。それは今のところ – JustasM
@ジャストマス、素晴らしいです。どういたしまして。私は喜んでお手伝いします。それがあなたを助けたと思えば、答えを受け入れることを忘れないでください。 – Ionut