$("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();
本文通过示例展示了如何使用jQuery创建自定义事件并触发这些事件,包括基本的事件绑定与触发流程,并且介绍了如何在自定义对话框组件中初始化触发事件。
740

被折叠的 条评论
为什么被折叠?



