Insert and delete multiple div using jQuery
<p>Hi I know how to add div dynamically when button click, and how to delete that div using jQuery:</p>

<pre><code>&lt;input type="button" class="adddiv" value="add" /&gt;
  &lt;div class="clean"&gt;
      msg 
    &lt;button class="close" value="close" &gt;
  &lt;/div&gt;

&lt;script&gt;
  $(".adddiv").on("click",function(){
     $('.clean').after('&lt;div class="clean main1"&gt;msg&lt;button class="close" value="close" /&gt;&lt;/div&gt;');
  });

 $(document).on("click",".close",function(){
    $(this).closest('div').remove();
 });

&lt;/script&gt;
</code></pre>

<p>But here I need to make restrict maximum number of clean div in the page is 5 . If user add more than 5 div i need to restrict . </p>

<p>How to do this ?</p>