Finally, the default behavior is triggered with the native Event trigger function (Click,focus). and setting a jQuery.event.triggered flag to flag is to trigger the default behavior and avoid triggering the event again.
Finally, the source code.Triggerfunction(Event, data, Elem, onlyhandlers) {//events can be event types, custom event objects, or jquery event objects vari, cur, tmp, Bubbletype, Ontype, handle, special, Eventpath= [Elem | | document],//Bubble Road StrengthType = Hasown.call (event, "type")? Event.type:event,//determine if an event is an object (custom and jquery) or a type stringnamespaces = Hasown.call (Event, "namespace")? Event.namespace.split ("."): [];//name Spacecur= TMP = Elem = Elem | | Document//cur an ancestor element that points to the current element //Don ' t do events on text and comment nodes if(Elem.nodetype = = = 3 | | elem.nodetype = = 8) {//exclude text nodes and comment nodes return; } //Focus/blur morphs to focusin/out, ensure we ' re not firing them right now Rfocusmorph =/^ (?: Focusinfocus|focusoutb Lur) $/, if(Rfocusmorph.test (type + jQuery.event.triggered)) {//filter out the default behavior of the Foces/blur event, followed by unified Focusin/focusout return; } if(Type.indexof (".") >= 0) {//resolving event types and namespaces and sorting namespaces //namespaced trigger; Create a regexp to match event type in handle ()namespaces = Type.split (".")); Type=Namespaces.shift (); Namespaces.sort (); } Ontype= Type.indexof (":") < 0 && "on" + type;//There are: no calls in inline listener events //Caller can pass in a Jquery.event object, object, or just an Event type stringevent = event[Jquery.expando]?//determine if the jquery listener object is not created. Event:NewJquery.event (Type,typeofevent = = = "Object" &&event); //Trigger Bitmask: & 1 for Native handlers, & 2 for JQuery (always true)Event.istrigger = onlyhandlers? 2:3; Event.namespace= Namespaces.join ("."); Event.namespace_re= Event.namespace?NewRegExp ("(^|\\.)" + namespaces.join ("\ \ (?:. *\\.|)") + "(\\.| $)" ) : NULL; //Clean up the event in case it is being reusedEvent.result = undefined;//The return value of the last function that has a return value if(!event.target) {//Fix TargetEvent.target =Elem; } //Clone any incoming data and prepend the event, creating the handler arg listdata = data = =NULL?//encapsulates additional data (if any) and event objects into an array. Easy to apply call[Event]: Jquery.makearray (data, [Event]); //Allow special events to draw outside the linesSpecial = jquery.event.special[Type] | | {}; if(!onlyhandlers && special.trigger && special.trigger.apply (elem, data) = = =false) {//the trigger function of the modified object is called first to trigger return; } //determine event propagation path in advance, per the events spec (#9951) structure bubbling Road strength //Bubble up-to-document, then-to-window; watch for a global ownerdocument var (#9724) if(!onlyhandlers &&!special.nobubble &&!jquery.iswindow (elem)) {//excludes onlyhandlers=true, load, and window objects.Bubbletype= Special.delegatetype | | Type//prioritize the properties of a remediation object if(!rfocusmorph.test (Bubbletype + type)) {//initializes the cur as the parent element of the current element (excludes Focus/blur)Cur =Cur.parentnode; } for(; cur; cur = cur.parentnode) {//TraverseEventpath.push (cur); TMP= cur;//tmp points to the topmost element that can be reached } //Only Add window if we got to document (e.g., not plain obj or detached DOM) if(TMP = = = (Elem.ownerdocument | | document)) {//If the top level is document then add windowEventpath.push (Tmp.defaultview | | tmp.parentwindow | |window); } } //Fire handlers on the event pathi = 0; while((cur = eventpath[i++]) &&!event.ispropagationstopped ()) {//traversing the bubbling path to trigger the listening functionEvent.type= i > 1?BubbleType:special.bindType||type; //JQuery HandlerHandle = (Data_priv.get (cur, "events") | | {}) [Event.type] && data_priv.get (cur, "handle");//Remove the main listener function if(handle) {//calling the main listener functionhandle.apply (cur, data); } //Native Handlerhandle = Ontype &&cur[Ontype]; if(Handle && handle.apply && jquery.acceptdata (cur)) {//perform in-line event listener functionsEvent.result =handle.apply (cur, data); if(Event.result = = =false) {//a return value of false means that the default behavior is blockedEvent.preventdefault (); } }} event.type= type;//Reply to type //If Nobody prevented the default action, do it now if(!onlyhandlers &&!event.isdefaultprevented ()) {//No default behavior is blocked if((!special._default | | special._default.apply (EVENTPATH.POP (), data) = = =false) &&Jquery.acceptdata (Elem)) { //Call A native DOM method on the target with the same name name as the event. //Don ' t do default actions in window, that's where global variables Be (#6170) if(Ontype && jquery.isfunction (elem[type]) &&!Jquery.iswindow (Elem)) { //Don ' t re-trigger an OnFoo event time we call its FOO () method avoids triggering the inline listener function againTMP =elem[Ontype]; if(TMP) {elem[Ontype]=NULL; } //Prevent re-triggering of the same event, since we already bubbled it above avoid triggering the main function againjQuery.event.triggered =type; elem[type] (); JQuery.event.triggered=undefined; if(TMP) {//Recoveryelem[Ontype] =tmp; } } } } returnEvent.result; },