代码如下:
<button type="button" class = "butt1" id ="submit" name ="submit" onclick="myAns(); this.disabled = true;"> Answer </button>
<script>
function myAns(){
for(var t=0; t <=count-1; t++) {
var table = document.getElementById("tableid");
var row = table.insertRow(t);
var cell1 = row.insertCell(0);
cell1.innerHTML =array[t];
}
}
</script>
答案 0 :(得分:0)
你的问题在这里:
cell1.innerHTML =array[t];
改为:
cell1.innerHTML = t;
<table id="tableid">
<tr>
<td>1</td>
</tr>
</table>
<button id="submit" onclick="a(event)">Click Me!</button>
<script>
document.getElementById('submit').removeAttribute('disabled');
function a(e)
{
for (var t = 0; t <= 5 - 1; t++)
{
var table = document.getElementById("tableid");
var row = table.insertRow(t);
var cell1 = row.insertCell(0);
cell1.innerHTML = t;
}
e.target.setAttribute('disabled', 'disabled');
}
</script>