I am creating table with input boxes and have used the following code to create new row.
I want new row should have blank values inside textboxes. For it I have tried class property to change but its not working and always get value from first row.
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", "");
}
}
document. You can also usegetElementsByClassNamedocumenton a specific element. Untested, but you could trynewcell.getElementsByClassName(instead (although better yet would be to loop through all elements after the loop withrow.getElementsByClassName)