感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
<div>
<p>
detct Calculator
</p>
<input type="text" readonly/>
<div class="box">
<button value="ac">
AC
</button>
<button value="ce">
CE
<button value="%">
%
<button value="/">
/
<button value="7">
7
<button value="8">
8
<button value="9">
9
<button value="*">
*
<button value="4">
4
<button value="5">
5
<button value="6">
6
<button value="-">
-
<button value="1">
1
<button value="2">
2
<button value="3">
3
<button value="+">
+
<button value=".">
.
<button value="0">
0
<button>
Ans
<button value="=">
=
</div>
xxxxxxxxxx
var clear=false;
$("button").click(function(){
var value = $(this).val()
if (value!=="ac"&&value!=="ce"&&value!=="="&&clear==false)
{
value=$("input").val()+value;
$("input").val(value)
}
else if (value=="ac"||clear==true)
{$("input").val("")
clear=false}
else if (value=="ce")
value=$("input").val();
value = value.substring(0,value.length-1);
else if (value=="=")
value = eval(value);
$("input").val(value);
clear=true
})
.box{
display:flex;
flex-wrap:wrap;
justify-content:center;
width:200px;
height:auto;
background-color:#C47335;
button{
flex-grow:1;
border:none;
width:40px;
height:40px;
margin:2px;
color:#F39973;
background-color:#FFFFFF;
div{
width:300px;
margin:auto;
overflow:auto;
text-align:center;
padding-bottom:10px;
border-radius:5px;
input{
width:196px;
height:2em;
text-align:right;
background-color:#F19953;
margin-bottom:2px;
p{
font-family: "Oleo Script",cursive;
color:#F19953;