I am making a website and I have a <textarea>
where people can type text. I want to add a button that will undo the last thing they did in the textarea, if they typed a word, it should come back when they press the button.
I found something about document.execCommand('undo')
, but I heard its not good to use anymore. Is there another way to do this with JavaScript?
Example:
- User types “Hello”.
- User deletes “ello”.
- I want to bring back the “ello” when they click the undo button.
Thanks!