ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[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"]); ```