How to track a field change through a script?

  • 0
    When I manually edit a field, everything is ok, but if I edit it through js, the handler does not work.
    document.getElementById("input").addEventListener("input", function(event){console.log(event);})
    document.getElementById("input").value = "7";
    JavaScript Anonymous, Nov 26, 2019

  • 1 Answers
  • 0
    If you believe StackOverFlow, then you need to trigger the event manually.

    let element = document.getElementById(id);
    element.dispatchEvent(new Event("change"));

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!