$("input").bind("myevent",function(event,msg1,msg2){ alert("msg1:"+msg1); }) $("input").click(function(){ $("input").trigger("myevent",["avalue","bvalue"]) });
自定义事件
var Common = {}; Common.Dialog = function(config){}; Common.Dialog.prototype = { height:310, init: function(){ jQuery.event.trigger("submit"); } }; var dlg = new Common.Dialog({height:200}); $(dlg).bind("submit",function(){alert("submit event")}); dlg.init();