Note that there are some explanatory texts on larger screens.

plurals
  1. POCloning a div with content doesn't work somehow
    text
    copied!<p>I have another div where it does work with this js code but somehow with this one it doesnt. Can anyone tell me why it doesnt work?</p> <pre><code>$(function () { var $scntDiv = $('#parts'); var i = $('#parts input').size()-1; $('#addField').on('click', function () { var part = '&lt;div id="parts' + i + '"&gt;&lt;span&gt;Part&lt;/span&gt; &lt;input type="text" id="auto_part' + i + '" name="auto_part' + i + '" /&gt;&lt;br/&gt;' + '&lt;span&gt;Description&lt;/span&gt; &lt;textarea type="text" id="auto_description' + i + '" name="auto_description' + i + '"&gt;&lt;/textarea&gt; &lt;br /&gt;' + '&lt;a href="#" class="removefield"&gt;Remove&lt;/a&gt;&lt;/div&gt;'; $scntDiv.after(part); $("#row_count").val(i); i++; return false; }); $(document).on("click", ".removefield", function () { if (i &gt; 2) { $("#row_count").val(i-2); $(this).parent('div').remove(); i--; } return false; }); }); $(function () { var $scntDiv = $('.brands'); var i = $('.brands select').size()-1; $('#addBrand').on('click', function () { var brand = "&lt;div class='brands'&gt;&lt;span&gt;Brands&lt;/span&gt;&lt;br /&gt;"+ '&lt;select&gt;'+ '&lt;option&gt;Audi&lt;/option&gt;'+ '&lt;option&gt;BMW&lt;/option&gt;'+ '&lt;option&gt;Mercedes&lt;/option&gt;'+ '&lt;/select&gt;'+ '&lt;/div&gt;'; $scntDiv.after(brand); $("#countBrand").val(i); i++; return false; }); $(document).on("click", ".removeBrand", function () { if (i &gt; 2) { $("#countBrand").val(i-2); $(this).parent('div').remove(); i--; } return false; }); }); </code></pre> <p>The first function works for me but the last one doesn't.</p> <p>Live demo: <a href="http://jsfiddle.net/rEUPx/" rel="nofollow">http://jsfiddle.net/rEUPx/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload