📜  检查输入数值何时上升或下降 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:17.151000             🧑  作者: Mango

代码示例1
let previous_value;

document.getElementById("input").addEventListener("change", function() {
  let value = document.getElementById("input").value;
  if (previous_value > value) {
    console.log("Decreased");
  } else if (previous_value < value) {
    console.log("Increased");
  }
  previous_value = value;
});