For example, if there is an event-hander for a click event like this,
$("#testButton").click(
function(){
console.log("inside testButton click");
}
);
We can use the following code to execute the above event handler as if the click event happened (almost) in the browser.
$("#testButton").trigger("click");
The one cavet is if you trigger an event which uses the position (x,y coordinates) or keycode (enter key etc.,) you may get error, since those are not passed when using the trigger function.
No comments:
Post a Comment