JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" />

JavaScript

$("input").change(function(){
    var $this = $(this);

    var prev = $this.data("prev");
    
    alert("Prev: " + prev + "\nNow: " + $this.val());
    
    $this.data("prev", $this.val());    
});