jQuery has its own event logging system, which is separate from DOM event logging. When we call $(something).click() , all registered jQuery handlers and registered onclick handlers will start, but nothing else will happen. For instance,
document.body.addEventListener('click', function() { alert('event') }, false); document.body.onclick = function() { alert('onclick'); }; $('body').click();
If you call document.body.onclick() , then only the second event and "onclick" will fire. To trigger both events, create an event object and send it for the considered element - the body in this case. You can find it here . Unsurprisingly, IE uses a different mechanism to do the same, and you need to call fireEvent .
Here's an example of a non-cross browser for modern browsers (taken from the MDC article above),
var clickEvent = document.createEvent('MouseEvents'); clickEvent.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); document.body.dispatchEvent(clickEvent);
source share