Javascript 如何生成动态文本字段?
如何在按下按钮时生成动态文本字段Javascript 如何生成动态文本字段?,javascript,html,Javascript,Html,如何在按下按钮时生成动态文本字段 <script> functiom click() { } </script> <body> <form name="s"> <input type="submit" onclick="click()"/> </form> </body> 函数单击(){ } 如果您的意思是动态添加文本字段,那么您可以使用如下内容: <script&g
<script>
functiom click() {
}
</script>
<body>
<form name="s">
<input type="submit" onclick="click()"/>
</form>
</body>
函数单击(){
}
如果您的意思是动态添加文本字段,那么您可以使用如下内容:
<script>
functiom click()
{
var field = document.createElement("input");
field.type = "text";
document.getElementById("myForm").appendChild(field);
}
</script>
<body>
<form name="s" id="myForm">
<input type="submit" onclick="click()"/>
</form>
函数单击()
{
var字段=document.createElement(“输入”);
field.type=“text”;
document.getElementById(“myForm”).appendChild(字段);
}
但我还是建议先读一本Javascript书籍。请进一步详细解释这个动态文本字段的作用。