title: Dynamically Declare Function in jQuery
body: <p>How can I dynamically create multiple functions of calendar() in my code?</p>
  
  <pre><code>function calendar(){
    new JsDatePick({
      useMode:2,
      target:'datepicker',
      dateFormat:'%m-%d-%Y',
      weekStartDay: 0
    });
  </code></pre>
  
  <p>Here's my attempt and I'm so close I can almost taste it:</p>
  
  <blockquote>
  <pre><code>$(function() {
      $("[id^='datepicker']").each(function() {
          var id = parseInt(this.id.replace("datepicker", ""));
  
          function calendar+id(){
              new JsDatePick({
                  useMode:2,
                  target:'datepicker'+id,
                  dateFormat:'%m-%d-%Y',
                  weekStartDay: 0
              });
          }
      });
  });
  </code></pre>
  </blockquote>