我需要从不唯一的矩阵单元中获取值。这个模型是原始模型的简化,原始模型是一个巨大的矩阵,这就是为什么我把 enfasis 放在这个模型上:document.getElementById("myTable").rows[0].cells[0]。XXXXXX _
目标:我应该在该指令中使用什么属性或方法来获取复选框(真/假)或(1,0)的值。
谢谢!!!!
<!DOCTYPE html>
<html>
<head>
<style>
table,
td {
border: 1px solid black;
}
</style>
</head>
<body>
<p>Tratando de obtener valores de los checkbox dentro de una tabla.</p>
<table id="myTable">
<tr>
<td id='C1'> <input type='checkbox' checked='checked'> </td>
<td id='C2'> <input type='checkbox' checked='checked'> </td>
</tr>
<tr>
<td id='C3'> <input type='checkbox' checked='checked'> </td>
<td id='C4'> <input type='checkbox' checked='checked'> </td>
</tr>
</table>
<p id="print1"></p>
<p id="print2"></p>
<p id="print3"></p>
<p id="print4"></p>
<br>
<button onclick="myFunction()">Intentarlo</button>
<script>
function myFunction() {
document.getElementById("print1").innerHTML = document.getElementById("myTable").rows[0].cells[0];
}
</script>
</body>
</html>