Hacker News new | ask | show | jobs
by nicolasMLV 3523 days ago
You could simplify this

  <script>
    var counter = 0;
    $(document).ready(function() {
      var $output = $('#output');  
      $('#increment').click(function() {
        counter++;
        $output.html(counter);
      });
      $output.html(counter);
    });
 </script>
with

  <script>
    var counter = 0;
    $(document).on('click', '#increment', function() {
        counter++;
        $('#output').html(counter);
    });
  </script>