title: Create child table when a button is clicked
body: <p>I'm trying to build a table that can be dynamically edited with HTML and Javascript.</p>
  
  <p>I have a button in a row of a parent table and I want to create a child table inside the parent table when a button is clicked.
  But my jquery is not called on click.</p>
  
  <p>Class name is .childtbl.</p>
  
  <p><strong>Edit</strong> </p>
  
  <p>I have create button colume propmotional title in every row. button is clickable only on first row and also I can create table row but in second row i am not able to crete table onlcick of button! I dont know why function is not call.You can see my code in snippet</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
      var i =0;
      $(".addmore").on('click', function () {
        // alert("ks");
          var count = $('#form_table')[0].rows.length;
          alert(count);
          var data = "&lt;tr class='case'&gt;&lt;td&gt;&lt;span id='snum" + count + "'&gt;" + count + ".&lt;/span&gt;&lt;/td&gt;";
          data += "&lt;td&gt;&lt;input class='form-control' type='text' name='wname[]'/&gt;&lt;/td&gt;&lt;td&gt;&lt;button type=\"button\" id='newtrbtn' class='btn btn-success childtbl'&gt;+ add new Title&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;";
          $('#form_table').append(data);
          i++;
      });
      $(".childtbl").on('click', function () {
  
          alert("come from second");
          var count1 = $('#form_table1')[0].rows.length;
          alert(count1);
          var data1 = "&lt;tr class='case1'&gt;&lt;td&gt;&lt;span id='snum1" + count1 + "'&gt;" + count1 + ".&lt;/span&gt;&lt;/td&gt;";
          data1 += "&lt;td&gt;Title:&lt;input class='form-control' type='text' name='wr[]'/&gt;&lt;/td&gt;&lt;/tr&gt;";
          $('#form_table1').append(data1);
          i++;
      });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;form id='test'  method="post"&gt;
      &lt;label class="label"&gt; &lt;strong&gt; Warishan Names &lt;strong&gt; &lt;/label&gt;
      &lt;div class="table-responsive"&gt;
          &lt;table id="form_table" class="table table-bordered"&gt;
              &lt;tr&gt;
                  &lt;th&gt;S. No&lt;/th&gt;
                  &lt;th&gt;Promotional Header&lt;/th&gt;
                  &lt;th&gt;promotional Titile&lt;/th&gt;
              &lt;/tr&gt;
              &lt;tr class='case'&gt;
                  &lt;td&gt;&lt;span id='snum'&gt;1.&lt;/span&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input class="form-control" type='text' name='wname[]'/&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;button type="button" class='btn btn-success childtbl'&gt;+ add new Title&lt;/button&gt; &lt;br&gt;
                      &lt;table id="form_table1" class="table table-bordered"&gt;
                          &lt;tr class='case1'&gt;
  &lt;!--                       
  
           &lt;td&gt;&lt;span id='snum1'&gt;1.&lt;/span&gt;&lt;/td&gt;--&gt;
      &lt;!--                            &lt;td&gt;&lt;input class="form-control" type='text' name='wr[]'/&gt;&lt;/td&gt;--&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;
                      &lt;/td&gt; &lt;/tr&gt;
              &lt;/table&gt;
              &lt;button type="button" class='btn btn-success addmore'&gt;+ add new Header&lt;/button&gt; &lt;br&gt;
      &lt;/div&gt;
      &lt;input type="submit" name="submit" value="Submit" class="btn btn-info"&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>