最佳答案
您可以创建一个类似于您的 HTML 代码的字符串,代表该行:
var new_row='<tr>'
+ '<td><input type="text" id="firstName" name="firstName"></td>'
+ '<td><input type="text" id="lastName" name="lastName"></td>'
+ '<td><input type="radio" id="gender" name="gender"></td>'
+ '</tr>';
我只创建了其中的一部分,您需要添加您的案例所需的所有内容。然后这个 JS 可用于将新行添加到您的表中:
document.getElementById('table_id').append(new_row);
关于javascript - 如何使用 Javascript、表值复选框、文本框、单选框、选择选项在表中添加行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49145432/