【问题标题】:How to run the input value with the function如何使用函数运行输入值
【发布时间】:2021-07-06 16:50:02
【问题描述】:
我已经用 JavaScript 编写了这个程序,通过插入值,结果会显示在控制台中并且它可以正常工作
但我想通过在输入中输入值来应用这些功能,
如果我没有正确解释,我很抱歉:)
请帮帮我,谢谢
HTML:
html image
JavaScript:
js image
【问题讨论】:
标签:
javascript
html
function
object
dom
【解决方案1】:
当输入改变时,您需要将函数与输入链接
document.querySelector('#income').addEventListener('change', (event) => {
addIncome(userAccount, event.target.value);
});
document.querySelector('#outcome').addEventListener('change', (event) => {
addOutgo(userAccount, event.target.value);
});