答案 0 :(得分:0)
但是,我找到了实现所需操作的方法:
var parser = (cell,i) => [
el => null,
el => el.firstChild.options[el.firstChild.selectedIndex].value,
el => null,
el => null,
el => el.firstChild.options[el.firstChild.selectedIndex].value,
el => el.firstChild.options[el.firstChild.selectedIndex].value,
el => el.firstChild.checked ? "✓" : "✗",
el => null
][i](cell);
function save(row) {
var cells = [...row.children];
prompt("Value of row 2:", cells.map(parser));
}
table {border-collapse: collapse;}
td {border: 1px solid #ccc; padding: 0.2em}
<table>
<tr>
<td>2</td>
<td><select>
<option value="2010">2010-2011</option>
<option value="2012">2012-2013</option>
<option value="2014">2014-2015</option>
<option value="2016">2016-2017</option>
</select></td>
<td>tmrd-3</td>
<td>tes</td>
<td><select>
<option value="1">Tes Kelas</option>
<option value="2">Julia Roberts</option>
<option value="3">William the Conqueror</option>
</select></td>
<td><select>
<option value="213">asdfassssssssssssss</option>
<option value="214">tyuuuuuuuuu</option>
<option value="215">cxvusyyssssss</option>
</select></td>
<td><input type="checkbox"></td>
<td><button onClick="save(this.parentNode.parentNode)">Simpan/Save</button></td>
</tr>
</table>