Javascript: Triggering a click event on a element
February 27th, 2010 by jeremychoneSometime, the jQuery(”#xx”).click() does not work. So, here is a way to do it directly:
var e = document.createEvent('MouseEvents');
e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
var r = $("#myElement").get(0).dispatchEvent(e);
Obviously, you can use the document.getElementById(”myElement”) if you do not want any jQuery dependency.