Undo programmatically added stuff

Type something, then click + stuff. Then try to undo (Ctrl+Z).

by David Iglesias

HTML

<input id="targetText" type="text" placeholder="type something" />
<input id="enterText" type="button" value="+ stuff" />

JavaScript

const inputText = window.targetText;
const button = window.enterText;

button.addEventListener('click', () => {
	inputText.value += ', stuff';
  inputText.focus();
});