Programmatic value change on input field is ignored by Ctrl-Z and can't be "undo"-ne

1.5k Views Asked by At

When I have an input field with a certain value in it, and some JavaScript changes its value, I used to be able to click into the field and hit Ctrl-Z in order to get the old value back.

It seems it doesn't work anymore, is that a recent update of the browsers? I am doing something wrong? Is there a way to make it work again?

setTimeout(function () {
  document.getElementById("name").value = ""
}, 2000);
<input type="text" id="name" value="Sylvain" />

0

There are 0 best solutions below