多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## .trigger() 进行手动触发 ### 语法 ``` .trigger( eventType [, extraParameters ] ) ``` ### 示例 #### hello world ``` $(".div1").on("myCustomEvent", function (event, myName) { console.log(myName);//{name:"idcpj"} }) $(".div1").on("click",function (event) { $(this).trigger("myCustomEvent",{name:"idcpj"}) }) ``` #### 触发表单 ``` $("form:first").trigger("submit") ``` #### 向事件中传入任意的数据 ``` $("p").click( function (event, a, b) { // when a normal click fires, a and b are undefined // for a trigger like below a refers to "foo" and b refers to "bar" } ).trigger("click", ["foo", "bar"]); ```