选择新选项时如何将输入数字重置回 0?

How to reset a input number back to 0 when a new option is selected?

我想在选择新选项时change/reset将输入字段归零。我可以将该值设置回 0,但我希望在输入字段中显示该值。

function inputField() {

  var weight = document.getElementById("weight").value;
  weight = 0;

  console.log(weight);
}
<form>
  <select id="pickOne" onChange="inputField()">
    <option id="optionOne" value="1">1</option>
    <option id="optionTwo" value="2">2</option>
  </select>
</form>

<input type="number" id="weight">

试试这个:

function inputField() {
  var weight = document.getElementById("weight");
  weight.value = 0;
}
<form>
  <select id="pickOne" onChange="inputField()">
    <option id="optionOne" value="1">1</option>
    <option id="optionTwo" value="2">2</option>
  </select>
</form>

<input type="number" id="weight">