MCPcopy Index your code
hub / github.com/components/jquery / on

Function on

jquery.js:4588–4647  ·  view source on GitHub ↗
( elem, types, selector, data, fn, one )

Source from the content-addressed store, hash-verified

4586}
4587
4588function on( elem, types, selector, data, fn, one ) {
4589 var origFn, type;
4590
4591 // Types can be a map of types/handlers
4592 if ( typeof types === "object" ) {
4593
4594 // ( types-Object, selector, data )
4595 if ( typeof selector !== "string" ) {
4596
4597 // ( types-Object, data )
4598 data = data || selector;
4599 selector = undefined;
4600 }
4601 for ( type in types ) {
4602 on( elem, type, selector, data, types[ type ], one );
4603 }
4604 return elem;
4605 }
4606
4607 if ( data == null && fn == null ) {
4608
4609 // ( types, fn )
4610 fn = selector;
4611 data = selector = undefined;
4612 } else if ( fn == null ) {
4613 if ( typeof selector === "string" ) {
4614
4615 // ( types, selector, fn )
4616 fn = data;
4617 data = undefined;
4618 } else {
4619
4620 // ( types, data, fn )
4621 fn = data;
4622 data = selector;
4623 selector = undefined;
4624 }
4625 }
4626 if ( fn === false ) {
4627 fn = returnFalse;
4628 } else if ( !fn ) {
4629 return elem;
4630 }
4631
4632 if ( one === 1 ) {
4633 origFn = fn;
4634 fn = function( event ) {
4635
4636 // Can use an empty set, since event contains the info
4637 jQuery().off( event );
4638 return origFn.apply( this, arguments );
4639 };
4640
4641 // Use same guid so caller can remove using origFn
4642 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4643 }
4644 return elem.each( function() {
4645 jQuery.event.add( this, types, fn, data, selector );

Callers 1

jquery.jsFile · 0.70

Calls 1

jQueryFunction · 0.70

Tested by

no test coverage detected