title: Call the same jQuery function both on load and on click
body: <p>In my "update" pages I have often the need to call the same jQuery function both on page load and on click of some checkbox, mostly like this:</p>
  
  <pre><code>function foo(){
      if ($('#mycheckbox').is(':checked')){
          $('.myclass').hide();
      } else {
          $('.myclass').show();
      }
  }
  
  $(function() {
  
      foo(); // this is launched on load
      $('#mycheckbox').click(function(){
          foo(); // this is launched on checkbox click
      })  
  
  });
  </code></pre>
  
  <p>On page load, the checkbox could be checked or not depending on database values: that's why I have the need to launch the foo(); on load</p>
  
  <p>Well, this works fine, but I always wondered if... there is a better or most elegant solution?
  Thanks in advance</p>