这玩意能用if循环写吗
function count() { var ipt1 = document.getElementById('ipt1').value; //获取第一个输入框的值 var ipt2 = document.getElementById('ipt2').value;//获取第二个输入框的值 var select1 = document.getElementById('select1').value;//获取选择框的值 var fruit = document.getElementById('fruit').value; //获取通过下拉框来选择的值来改变加减乘除的运算法则 if (select1 == '+') { fruit = ipt1 + ipt2; return fruit; } else if (select1 == '-') { fruit = ipt1 - ipt2; return fruit; } else if (select1 == '*') { fruit = ipt1 * ipt2; return fruit; } else (select1 == '/') { fruit = ipt1 / ipt2; return fruit; } }
我写了个,控制台没报错,运行也无果