 <p>First your code is few issues, Any way try this,</p> <p>JsFiddle <a href="http://jsfiddle.net/dhana36/dy5Kk/" rel="nofollow">Example</a></p> <pre><code>$(function() { var counter =2; $("#addButton2").click(function () { var newTextBoxDiv2 = $(document.createElement('div')).attr("id", 'TextBoxDiv2' + counter); newTextBoxDiv2.after().html("&lt;table width='1200' border='0' cellspacing='0' cellpadding='0'&gt;&lt;tr&gt;&lt;td&gt;Date&lt;/td&gt;&lt;td&gt;&lt;li class='demo'&gt;&lt;div class='box'&gt;&lt;input class='multi' type='text' id='from-input_"+counter+"' maxlength='10'&gt;&lt;/div&gt;&lt;div class='code-box' style='display:none;'&gt;$('#from-input').multiDatesPicker();&lt;pre class='code prettyprint'&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"); newTextBoxDiv2.appendTo("#TextBoxesGroup2"); $("#from-input_"+counter).multiDatesPicker(); counter++; }); }); </code></pre>