JavaScript optimization – Event delegation - jQuery style

In one of previous posts I described event delegation. This time its time to make it better in jQuery.

What if you have a multiple click events? (or any other events) Code can look like this:

      .on('click','.elem1', function(){ // your body})
      .on('click','.elem2', function(){ // your body})

Ive recreated it like this:

                click: function(e) {
                    var t = $(;

                    if (t.hasClass('elem1')) {
                       // your body

                    if (t.hasClass('elem2')) {
                        // your body