First of all, the difference between your two codes is that you once attach the event directly to the button and after binding to the body element and delegate any .buttom element inside the body (it does not matter when the ".button" element is created.
There is no shortage of using .on ('event', 'selector', function () {}), since .click (function () {}) is an alias for .on ('click', function () {}).
For latebindings, you should check the .delegate => http://api.jquery.com/delegate/ function. This binds the event to any selected item, now or in the function. There is no real difference in using .on or .delegate in your case, since .on replaces the .delegate function. However, I prefer to use .delegate, as it is easier for me to see what I'm doing here, and easier to maintain / understand the code after a few years.
$('body').delegate('.button', 'click', function() {
The last thing to mention is that you should avoid binding everything to the body, document, or what ever and delegate it to this element. You need to be as precise as possible with snaps to avoid unwanted behavior. You can support, expand and understand what happens where you define the areas in which you want them to take place. How to use containers for your content, etc.
source share