JS动态添加标签
如代码示例,使用jquery,动态的增加标签:
function addDiv(serial) {
//最外层父div
var div = document.createElement("div");
document.getElementById("form").appendChild(div);
var childDiv1 = document.createElement("div");
document.getElementById(div.id).appendChild(childDiv1);
var label1 = document.createElement("label");
document.getElementById(childDiv1.id).appendChild(label1);
var childDiv1_1 = document.createElement("div");
document.getElementById(childDiv1.id).appendChild(childDiv1_1);
var input1 = document.createElement("input");
document.getElementById(childDiv1_1.id).appendChild(input1);
}