Is there a way to pass the event that caused a change event to the change event function? I basically have a method that programmatically clicks a radio button. This calls the change function and I need to know if the original click was done by a human or done programmatically.
// This will trigger a change event on both input names menu1 and menu2.
$("#menu1").on("click", function() {
$("#menu2A").click();
});
$("input [name='menu1'], input [name='menu2']").on("change", function(e) {
var inputName = $($(e)[0].target).attr("name");
if (inputName === "menu2") {
// This is where I want to check that the click event was initiated by a human.
}
});
I tried creating a $("input[name='menu2'].on("click", function...)
that calls e.preventDefault()
to check the click event, but that didn't work. It hit the change function before it hit the click function. This is why I figured I needed to check the click event within the change event function.