title: Use JQuery Datepicker on dynamically created fields
body: <p>I have to use datepicker in wordpress site, in which a plugin creates fields dynamically with same name(array), same #id and same .class i try to use it using focus but i got error on it </p>
  
  <pre><code>TypeError: inst is undefined
  </code></pre>
  
  <p>Please hel</p>
  
  <pre><code>   &lt;html&gt;
          &lt;head&gt;
              &lt;title&gt;TODO supply a title&lt;/title&gt;
              &lt;meta charset="UTF-8"&gt;
              &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
              &lt;link href="assests/jquery-ui.min.css" rel="stylesheet"&gt;
              &lt;script src="assests/jquery.js"&gt;&lt;/script&gt;
              &lt;script src="assests/jquery-ui.js"&gt;&lt;/script&gt;
          &lt;/head&gt;
          &lt;body&gt;
              &lt;div class="mytemplate" style="display: none;"&gt;
                  &lt;input id="datepicker" type="text" name="name[]"&gt;
              &lt;/div&gt;
              &lt;div class="dates"&gt;
              &lt;div&gt;
                  &lt;input id="datepicker" type="text" name="name[]"&gt;
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;input type="button" value="Add more" onclick="myfunction()"&gt;
              &lt;script&gt;
                  function myfunction() {
                      $(".mytemplate").clone().removeClass("mytemplate").show().appendTo(".dates");
                  }
              &lt;/script&gt;
              &lt;script&gt;
                  $(document).on("focus", "#datepicker", function(){
                      $(this).datepicker();
                  });
              &lt;/script&gt;
          &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>