Consolidate .on function I have two .on() functions for separate dynamically added elements, they are:

$('body').on('click', 'img', function() {
   modal(content[$('li.active a').attr("href")].images[$("img").index(this)]);
});
$('body').on('click', 'img', function() {
   closeM();
});


The second function, I have shortened to

$("body").on("click", "#close", closeM);


In looking at the jQuery documentation for .on(), I saw that I can do something like:

$("body").on({
  click: function(){
  },
  mouseenter: function() {
  }
});


I was wondering if I could either do something like that with my previous two functions, or if there was any other way of shortening/combining them.
You could just do both operations inside the anonymous function (that you are sending as third parameter).

$('body').on('click', 'img', function() {
   modal(content[$('li.active a').attr("href")].images[$("img").index(this)]);
   closeM();
});


Also, I would consider simplifying the first instruction by breaking it down into smaller pieces.
All compressed together as it is, it is some serious black magic and should be quite tough to read or maintain by anyone else.



But $("body").on("click", "#close", closeM); is very simple, and also much more contained because it applies to the only element with id #close in the HTML, instead of to all the images. So I would prefer to leave it separate.