JS動的ラベル追加
921 ワード
JS動的ラベル追加
コードの例のように、jqueryを使用してラベルを動的に追加します.
コードの例のように、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);
}