With jQuery
, I would like to trigger a keypress
event where the event is handled by another version of jQuery
.
jQuery2 = jQuery.noConflict(true);
$(function(){
$("#fff").keypress(function(event) {
if (event.which == 13) { alert('jQuery'); }
});
jQuery2('#fff').trigger(jQuery2.Event("keypress",{keyCode:13, which:13}));
});
Note that the handler is defined with $
while the event is triggered with jQuery2
.
Here is a demo: jsfiddle. The handler code doesn't run!
Please help!