如何通过JavaScript动态生成html控件

2025-02-01 12:59:59
推荐回答(3个)
回答1:





无标题文档







回答2:

可以这么写:
var input = document.createElement("input");
document.body.appendChild(input);
也可以这么写,例如你想要添加的控件在id为"divId"这个div上显示
document.getElementById("divId").innerHTML = '';

回答3:

function createInput(){
var input = document.createElement("input");
document.body.appendChild(input);
}