what's the equivalent of jquery's 'trigger' method without jquery?

event.initMouseEvent("click"...

Here is an example:

function simulateClick(elId) {
    var evt;
    var el = document.getElementById(elId);
    if (document.createEvent) {
        evt = document.createEvent("MouseEvents");
        evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
    }
    (evt) ? el.dispatchEvent(evt) : (el.click && el.click());
}

var foo = document.getElementById("hey");

foo.onclick = function () {alert("bar");}

simulateClick("hey");

For some value of "a very shoddy equivalent":

var button = document.getElementById("thebutton")
button.click()

Not all browsers (e.g. Firefox!) allow simulated events this way! Using onclick() only works if the event is in-line, etc.

Please see the jQuery source and search for "trigger:" (first match) to see all the icky stuff done to "make it work" (a good bit of it is just munging around the jQuery internals, other frameworks make have much simpler examples).

Happy coding.