问题在于之后的所有内容的输出。
let button = document.querySelectorAll(".number"),
clear = document.getElementById("clear"),
textview = document.getElementById("textview"),
result = document.getElementById("result"),
del = document.getElementById("delete");
for( let b in button ){
button[b].addEventListener("click", function(){
return textview.value += button[b].value;
});} // output data
clear.addEventListener("click", function(){
return textview.value = " ";
}); //clear
result.addEventListener("click", function(){
return textview.value = eval(textview.value);
}); //result
del.addEventListener("click", function(){
return textview.value = (textview.value).slice(0, -1);
});
querySelectorAll
返回的不是一个数组,而是一个类似数组的对象。不正确:
正确:
或者