JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id="enter-text"></textarea>
<div id="drag-area-selected">

</div>
<button id="undo_text">
undo
</button>
<button id="redo_text">
Redo
</button>
</button>

CSS

a

JavaScript

var stack = [],
  lastItem;

jQuery('#enter-text').keypress(function() {
  console.log(jQuery('#enter-text').val());
  jQuery("#drag-area-selected").text(jQuery('#enter-text').val());
  stack.push(jQuery('#enter-text').val());
});

jQuery('#undo_text').click(function() {
  lastItem = stack.pop();
});

jQuery('#redo_text').click(function() {
  if (lastItem) {
    stack.push(lastItem);
  }
});