1$( "#foo" ).on( "click", function() {
2 alert( $( this ).text() );
3});
4$( "#foo" ).trigger( "click" );
5
6$( "#foo" ).on( "custom", function( event, param1, param2 ) {
7 alert( param1 + "\n" + param2 );
8});
9$( "#foo").trigger( "custom", [ "Custom", "Event" ] );
1
2
3$('body').trigger('this_works', [{data: [1, 2, 3]}, 'something']);
4
5$('body').on('this_works', function (event, json, string) {
6 // parameter is stocked in json.data here.
7 console.log(event, json, string);
8});
1// There are quite a few abstracted versions of the following
2$('element').on('event', function() {
3 // Do something
4});
5
6// Where 'event' is something such as 'click', 'hover' etc
7
8// They are abstracted as seen below
9$('element').click(function(){
10 // Do something
11});
12$('element').hover(function(){
13 // Do something
14});
15
16// etc...