入力ボックスでテーブルを作成していますが、次のコードを使用して新しい行を作成しました。クラス入力値をjavascriptで変更します
新しい行にはテキストボックス内の空白の値が必要です。私はクラスプロパティを変更しようとしましたが、動作していないので、常に最初の行から値を取得します。
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
// limit the user from creating fields more than your limits
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[1].cells[i].innerHTML;
document.getElementsByClassName('small')[0].setAttribute("value", "");
}
}
try-できるコードは 'document'のすべての要素を検索します。特定の要素に対して 'getElementsByClassNamedocument'を使うこともできます。あなたは 'newcell.getElementsByClassName(')を試してみることができます(より良いのは、 'row.getElementsByClassName'でループの後のすべての要素をループすることです) –