Using jQuery access click event of two buttons with same function

I have seen a lot of people doing this .. if they want to perform same operation with two buttons using jquery.
$('#Button1').click(function () {
   // code here
})

$('#Button2').click(function () {
 // same code here
})
but the easier way is
$('#Button1, #Button2').click(function() {
    // You can use 'this' to refer to the source element, for instance:
    $(this).css("background-color", "blue");
});
Cheers :)