function additon() {
const value_1 = document.getElementById('value_1').value;
const value_2 = document.getElementById('value_2').value;
const answer = document.getElementById('answer');
var additon = (value_1 + value_2);
answer.innerHTML = additon;
}
function subtraction(){
const value_1 = document.getElementById('value_1').value;
const value_2 = document.getElementById('value_2').value;
const answer = document.getElementById('answer');
var subtraction = (value_1 - value_2);
answer.innerHTML = subtraction;
}
Enter value 1 <input type="tel" id="value_1">
<br>
Enter value 2 <input type="tel" id="value_2">
<br>
Answer: <span class="answer" id="answer"></span>
<br>
<button class="btn btn-success btn-lg" onclick="additon()">+</button>
<button class="btn btn-danger btn-lg" onclick="subtraction()">-</button>
<button class="btn btn-succes btn-lg" onclick="multiplication()">X</button>
<button class="btn btn-succes btn-lg" onclick="division()">/</button>
为什么要加1 + 1 = 11。减法工作正确以及如何为值输入创建全局变量我想成为一个实时更新的计算器。
陪伴而非守候
MM们
肥皂起泡泡
相关分类