title: Attach jQuery inputmask to DOM element
body: <p>I'm using RobinHerbot's inputmask and can't seem to figure out how to attach it to DOM elements.  I've come across a couple "solutions," but none that work the way I'm creating the new fields.  I tried creating a function to attach it to newly added fields because I know the code won't work on DOMs in the document ready function, but that didn't prove to be helpful either.</p>
  
  <p>Here's a jsfiddle example: <a href="https://jsfiddle.net/hnj6ed1y/40/" rel="nofollow">jsfiddle</a></p>
  
  <p><strong>JS</strong></p>
  
  <pre><code>var count_2 = 5;
  
  $(document).ready(function () {
  
      $('#btnAdd').click(function () {
          count_2 = count_2 + 2;
          $('#Table tr:last').after('&lt;tr&gt;&lt;td&gt;' + 
              '&lt;p class=\"null_temp\"&gt;' +
              '&lt;input type=\"text\" name=\"temp' + count_2 + '\" id=\"temp' + count_2 + '\" placeholder=\"Time\" size=\"10\" maxlength=\"8\" value=\"\" class=\"total_time_regex\" /&gt;' +
              '&lt;/td&gt;&lt;/tr&gt;');
      });
  
          $('.total_time_regex').inputmask('Regex', { 
              regex: "^([0-9]{1,4}:[0-5][0-9])$"
          });
  });
  
  $(function() {
      $('.total_time_regex').inputmask('Regex', { 
          regex: "^([-][0-9]{1,4}:[0-5][0-9])|([0-9]{1,4}:[0-5][0-9])$"
      });
  });
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;table style="width: 70%" id="Table" name="Table"&gt;
      &lt;tr&gt;
          &lt;th&gt;Time&lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;
              &lt;p class="null_temp"&gt;
                  &lt;input type="text" name="temp1" id="temp1" placeholder="Time" size="10" maxlength="8" value="" class="total_time_regex" /&gt;
              &lt;/p&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;input type="button" id="btnAdd" name="btnAdd" value="Add More" class="button" /&gt;
  </code></pre>
  
  <p><strong>CSS</strong></p>
  
  <pre><code>#Table {
      font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
      border-collapse:collapse;
  }
  #Table td, #Table th {
      font-size:1em;
      border:1px solid #98bf21;
      padding:3px 7px 2px 7px;
  }
  #Table th {
      font-size:1.4em;
      text-align:left;
      padding-top:5px;
      padding-bottom:4px;
      background-color:#A7C942;
      color:#fff;
  }
  #Table tr.alt td {
      color:#000;
      background-color:#EAF2D3;
  }
  </code></pre>
  
  <p>Truly appreciate the help as I'm still learning how to deal with DOM elements.  Thank you in advance!</p>