JSFiddle - React, Tailwind, and code Playground
by dshilkret
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<input id="txt" type="text" value="Hello World"> <input id="chx" type="checkbox" /><br><br>
<button id="btn1">Trigger the select event for the input field</button>
<button id="btn2">button 2</button>
<p>Notice that, unlike the trigger() method, the triggerHandler() method does not cause the default behavior of the event to occur (The text is not marked).</p>
JavaScript
$(document).ready(function(){
$("input").select(function(){
$("input").after(" Select event triggered!");
});
$("#btn1").click(function(){
alert("dogs");
});
$("input").change(function(){
$("input").triggerHandler("blur");
$("#btn1").triggerHandler("click");
});
$("#btn2").click(function(){
$("#txt").val("changed text");
check();
});
$("#chx").change(function(){
if(check())
{
alert("checked");
}
else
{
alert("unchecked");
}
});
});
function check() {
document.getElementById("chx").checked = true;
}
function uncheck() {
document.getElementById("chx").checked = false;
}