点击提交按钮后,按钮下方会出现一个表格。在这里"你好世界"出现。我想要一个输入字段

时间:2018-04-01 13:04:11

标签: javascript html onclick

1 个答案:

答案 0 :(得分:1)

here is how you can create your own input field

var container = document.getElementById("container")


function myFunction() {
    var input =  document.createElement("input")
    input.type="text";
    input.placeholder="Hello i am a new input"
    container.appendChild(input)

}
<!DOCTYPE html>
<html>
<body>

<p>Click the button to trigger a function that will create an input field </p>
<button onclick="myFunction()">Click me</button>
<div id="container"></div>

</body>
</html>