event Keyword .. what does it really do ? why is it used in Jquery .
Picked this example from the Jquery Docs of on function :
What really would happen without the event keyword(Marked in red) in the code below :
- $( "p" ).on( "myCustomEvent", function( event, myName ) {
- $( this ).text( myName + ", hi there!" );
- $( "span" ).css( "opacity", 1 ).text( "myName = " + myName ).fadeIn( 30 ).fadeOut( 1000 );
- });
- $( "button" ).click(function () {
- $( "p" ).trigger( "myCustomEvent", [ "John" ] );
- });
got the example from here :