慕慕4380654
2018-12-04 14:28
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>VUE</title>
<script type="text/javascript"src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
function cli(){
var a = document.getElementById("a").value;
var b = document.getElementById("b").value;
var s = document.getElementById("s").value;
var c = document.getElementById("c").value;
if (s=="+") {
c=parseInt(a)+parseInt(b);
}else if (s=="-") {
c=parseInt(a)-parseInt(b);
}else if (s=="*") {
c=parseInt(a)*parseInt(b);
}else if (s=="/") {
c=parseInt(a)/parseInt(b);
};
}
</script>
</head>
<body>
<input type="text" value=""id="a">
<select name="" id="s">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text"value="" id="b">
<button onclick="cli()">=</button>
<input type="text" id="c">
</body>
</html>
function cli() { var a = document.getElementById("a").value; var b = document.getElementById("b").value; var s = document.getElementById("s").value; var c = ""; if(s == "+") { c = parseInt(a) + parseInt(b); } else if(s == "-") { c = parseInt(a) - parseInt(b); } else if(s == "*") { c = parseInt(a) * parseInt(b); } else if(s == "/") { c = parseInt(a) / parseInt(b); }; document.getElementById("c").value = c; }
咱俩的区别好像就是这个放的位置不同。有点想不通。。谢谢啦
噢原来你在学VUE
我惊呆了,还引用了JQ?用switch鸭
JavaScript进阶篇
468192 学习 · 21891 问题
相似问题