JSFiddle - React, Tailwind, and code Playground
HTML
Sample Input (DO NOT TYPE IN ME!!)
<p>
<input id="sample" />
<p>Click the buton new vale is set and the change is triggered
<p>
<button id="aButton">click me</input>
JavaScript
//global function to force trigger call when input change
(function ($) {
var originalVal = $.fn.val;
$.fn.val = function (value) {
this.trigger("change");
return originalVal.call(this, value);
};
})(jQuery);
$("#aButton").click(function () {
//value is set in input which does not trigger the change
$("#sample").val("new value");
})
$("#sample").change(function () {
alert("no one typed in me but my change event triggered");
})