This is my code:
$("input[type=text]").on("input", function(){
console.log("input event fired.");
})
$("input[type=button]").on("click", function(){
var event = new Event('input');
$("input[type=text]").dispatchEvent(event);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" placeholder="write .." />
<input type="button" value="emulate input event" />
As you can see, when you write something into the input, input event works as well. How can I emulate that event when you click on the button?