https://jsfiddle.net/yarkov_aleksei/1d4uv3eL/6/
<textarea cols="60" rows="10"></textarea>
<button id="cancel">Cancel</button>
<button id="save">Save</button>
const textarea = document.querySelector('textarea');
const cancelButton = document.querySelector('#cancel');
const saveButton = document.querySelector('#save');
saveButton.addEventListener('click', (e) => {
textarea.dataset.initialValue = textarea.value;
});
cancelButton.addEventListener('click', (e) => {
textarea.value = (textarea.dataset.initialValue || '');
});