【发布时间】:2021-11-19 01:47:33
【问题描述】:
我在 Html 中有一个表单标签:
app.get("/",(req,res)=>{
res.sendFile(__dirname+"/index.html")
})
app.post("/Cong",urlencodedParser,(req,res)=>{
var a = parseInt(req.body.a);
var b = parseInt(req.body.b);
var c = a + b;
res.send("Result: "+c)//This is will route to a new website, but I just want change text in my HTML
})
<form action="/Cong" method="post">
A: <input type="text" name="a"><br>
B: <input type="text" name="b"><br>
<label id="result"></label>
</form>
当我单击按钮时,如何在文件 js 中使用 id result = value C 更改 HTML 中的标签。
【问题讨论】:
标签: javascript html node.js web post