Consider the following HTML:
This article gives a good overview of the topic:
Triggering Event Handlers
Basically, trigger
will only fire event handlers attached through jQuery or certain event handler attributes in the html.
You can define a plugin to trigger a native browser event like this:
(function($) {
$.fn.trigger2 = function(eventName) {
return this.each(function() {
var el = $(this).get(0);
triggerNativeEvent(el, eventName);
});
};
function triggerNativeEvent(el, eventName){
if (el.fireEvent) { // < IE9
(el.fireEvent('on' + eventName));
} else {
var evt = document.createEvent('Events');
evt.initEvent(eventName, true, false);
el.dispatchEvent(evt);
}
}
}(jQuery));
// sample usage
$('select').trigger2('change');
This is not perfect but should give you the general idea.
Here's an update to your fiddle using this plugin.