.calculator-body{
\t padding-top: 20px;
}
.calculator-monitor{
border-radius: 5px;
background-color: rgba(128, 128, 128, 0.09);
\t margin-bottom: 10px;
\t text-align-last: right;
\t padding: 10px;
}
.btn{
\t width: 40px;
\t height: 40px;
\t margin: 2px 1px;
\t padding: 5px 15px;
}
<!DOCTYPE html>
<html>
<head>
\t <title>cALCULATOR</title>
\t <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
\t <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
\t <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
\t <link rel="stylesheet" type="text/css" href="css/style.css">
\t <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
\t <script type="text/javascript" src="js/js.js"></script>
</head>
<body>
\t <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
\t <div class="container">
\t \t <div class="row text-center">
\t \t \t <div class="col-xs-12 col-sm-6 col-sm-offset-3 bg main-block" id="mainBlock">
\t \t \t \t <div class="calculator-body">
\t \t \t \t \t <div class="row calculator-screen-row">
\t \t \t \t \t \t <input type="text" name="" class="calculator-monitor" placeholder="0">
\t \t \t \t \t </div>
\t \t \t \t \t <div class="row buttons-row first-buttons-row">
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="7">7</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="8">8</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="9">9</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button">/</button>
\t \t \t \t \t </div>
\t \t \t \t \t <div class="row buttons-row first-buttons-row">
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="4">4</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="5">5</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="6">6</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button">x</button>
\t \t \t \t \t </div>
\t \t \t \t \t <div class="row buttons-row first-buttons-row">
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="1">1</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="2">2</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="3">3</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button">-</button>
\t \t \t \t \t </div>
\t \t \t \t \t <div class="row buttons-row first-buttons-row">
\t \t \t \t \t \t <button class="btn btn-default calculator-button number-button" value="0">0</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button">.</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button">+</button>
\t \t \t \t \t \t <button class="btn btn-default calculator-button">=</button>
\t \t \t \t \t </div>
\t \t \t \t </div>
\t \t \t </div>
\t \t </div>
\t </div>
</body>
</html>
大家好,其實我是新編碼中,尤其是在JS。 現在我需要用一些操作來製作一個簡單的計算器。 我嘗試了幾種方法,但沒有一個是正確的。 我需要onclick的一些數字,輸入的值被更改爲按鈕(數字)的值。 我該如何管理它,我會很高興看到使用jQuery的答案。
http://codepen.io/simonja2/pen/QbGYbR –