title: Limit maximum number of table rows using Jquery
body: <p>I am using following code to generate a dynamic input table. How to limit maximum input rows to 10?</p>
  <pre><code>$(document).ready(function () {
      var counter = 0;
  
      $(&quot;#addrow&quot;).on(&quot;click&quot;, function () {
          var newRow = $(&quot;&lt;tr&gt;&quot;);
          var cols = &quot;&quot;;
  
          cols += '&lt;td&gt;&lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; name=&quot;idetails[]' + counter + '&quot;&gt;&lt;/td&gt;';
          cols += '&lt;td&gt;&lt;input type=&quot;date&quot; class=&quot;form-control form-control-sm&quot; name=&quot;idate[]' + counter + '&quot;&gt;&lt;/td&gt;';
          cols += '&lt;td&gt;&lt;input type=&quot;text&quot; class=&quot;form-control form-control-sm&quot; name=&quot;iamount[]' + counter + '&quot;&gt;&lt;/td&gt;';
  
          cols += '&lt;td&gt;&lt;input type=&quot;button&quot; class=&quot;delrow btn btn-danger&quot;  value=&quot;Delete&quot;&gt;&lt;/td&gt;';
          newRow.append(cols);
          $(&quot;table&quot;).append(newRow);
          counter++;
      });
  
      $(&quot;table&quot;).on(&quot;click&quot;, &quot;.delrow&quot;, function (event) {
          $(this).closest(&quot;tr&quot;).remove();
          counter -= 1
      });
  });
  </code></pre>