灬紫羽
html>
JAVASCRIPT计算器/*Basic reset*/
*{
margin:0;
padding:0;
box-sizing: border-box;
font: 14px Arial,sans-serif;
}
html{
height:100%;
background-color:lightslategrey;
}
#calculator{
margin: 15px auto;
width:330px;
height:400px;
border: 1px solid lightgray;
background-color:darkgrey;
padding:15px;
}
/*LOGO*/
.LOGO{
height:20px;
}
.LOGO .name{
float:left;
line-height:30px;
}
.LOGO .verson{
float:right;
line-height:30px;
}
/*screen*/
#shuRu{
margin-top:15px;
}
.screen{
margin-top:5px;
width:300px;
height:40px;
text-align: right;
padding-right:10px;
font-size:20px;
}
#keys{
border:1px solid lightgray;
height:223px;
margin-top:25px;
padding:8px;
}
#keys .last{
margin-right:0px;
}
.footer{
margin-top:20px;
height:20px;
text-align: center;
}
#keys .buttons{
float:left;
width: 42px;
height: 36px;
text-align:center;
background-color:lightgray;
margin: 0 17px 20px 0;
}
简单的计算器
@mumu
欢迎使用JavaScript计算器
var num = 0; // 定义第一个输入的数据
//获取当前输入
function jsq(num) {
if(num=="%"){
document.getElementById('screenName').value=Math.round(document.getElementById('screenName').value)/100;
}else{
document.getElementById('screenName').value += document.getElementById(num).value;
}
}
//计算输入结果
function eva() {
document.getElementById("screenName").value = eval(document.getElementById("screenName").value);
}
//清0
function clearNum() {
document.getElementById("screenName").value = null;
document.getElementById("screenName").focus();
}
//退格
function tuiGe() {
var arr = document.getElementById("screenName");
arr.value = arr.value.substring(0, arr.value.length - 1);
}