比如加法运算:
输入:
3
1 2
1 3
1 4
输出:
3
4
5
使用的是for循环调用console.log()
对每一行的输入都有对应的输出的多行输入多行输出的问题可以使用如下方法:
输入:
1 2
1 3
1 4
输出:
3
4
5
function checkLe(text){if(text.value.length>2){
text.value=text.value.substring(0,2)
}
}
<input type="text" onkeyup="checkLe(this)">
<input type="text" onkeyup="checkLe(this)">
<input type="text" onkeyup="checkLe(this)">