title: Delete div with JavaScript
body: <p>In my View, I'm dynamically add divs like this via JS:</p>
  
  <pre><code>&lt;div id="detail[0]"&gt;
          &lt;input name="detail.Index" type="hidden" value="0" /&gt;
          &lt;input name="detail[0].details_name" type="text" /&gt;
          &lt;input name="detail[0].details_value" type="text" /&gt;
          &lt;input class="btn" type="button" value="Delete" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The question is how to delete the chosen one by clicking the Delete button in div?</p>
  
  <p>JavaScript that adds new divs:</p>
  
  <pre><code>&lt;script&gt;
  $(function() {
      var i = 0;
      $('.plus').click(function()
      {
          ++i;
          var html2add = "&lt;div id='detail[" + i + "]'&gt;" +
              "&lt;input name='detail.Index' type='hidden' value='" + i + "' /&gt;" +
              "&lt;input name='detail[" + i + "].details_name' type='text' /&gt;" +
              "&lt;input name='detail[" + i + "].details_value' type='text' /&gt;" +
              "&lt;input class='btn' type='button' value='Delete' /&gt;"+
              "&lt;/div&gt;";
          $('#details_part').append(html2add);
      })
  })
  </code></pre>
  
  <p></p>