gpt4 book ai didi

javascript - 定义输入未定义? (十六进制是什么?)

转载 作者:行者123 更新时间:2023-11-28 15:08:00 24 4
gpt4 key购买 nike

我遇到了一个奇怪的错误。虽然我定义了“输入”,但系统仍然说“嘿伙计,你没有定义“输入”,也许你应该再次检查你的代码。”。这确实让我很困惑。所以,这是我的代码:

 var txt = document.createElement("input");
txt.type = "text"
txt.placeholder = "Your answer is: ";
document.getElementById("form").appendChild(input);

因为我是 javascript 新手,所以请简单一些。非常感谢您的帮助。

最佳答案

您需要将您的appendChild更改为此

var txt = document.createElement("input");
txt.type = "text"
txt.placeholder = "Your answer is: ";
document.getElementById("form").appendChild(txt);

否则您将尝试添加 undefined object 。

关于javascript - 定义输入未定义? (十六进制是什么?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38046579/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com