Edit in JSFiddle

$(function() {
  $('#sample_button').click((function() {
    var cnt = 0;
    return function() {
      ++cnt;
      alert('You have clicked ' + cnt + ' times.');
    };
  })());
});
<button id="sample_button">
  Click Me, Please.
</button>