在表格中使用带有oninput的HTML5表单

时间:2016-02-08 09:14:27

标签: html5 html-table

任何人都可以解释为什么我不能在表格中使用oninput以及我如何让它工作?

例如,这有效:

<form onsubmit="return false" oninput="o.value = parseInt(a.value) + parseInt(b.value)">
  <input name="a" type="number" step="any"> +
  <input name="b" type="number" step="any"> =
  <output name="o"></output>
</form>

这不是:

<table>
<form onsubmit="return false" oninput="o.value = parseInt(a.value) + parseInt(b.value)">
  <input name="a" type="number" step="any"> +
  <input name="b" type="number" step="any"> =
  <output name="o"></output>
</form>
</table>

1 个答案:

答案 0 :(得分:0)

<form onsubmit="return false" oninput="o.value = parseInt(a.value) + parseInt(b.value)">
<table>

  <input name="a" type="number" step="any"> +
 <input name="b" type="number" step="any"> =
  <output name="o"></output>

</table>
</form>