I am cloning following div and I want to create newids on every clone. and it is doing like that but it is creating div as separate and inputs as separate out side div and all design messup. I want following div_ clone withall inputs should appear in other div container.
HTML
<div id="div_" style="display: none;" class="well form-inline">
<label>Label :</label> <input type="text" id="txtlabel" name="txtlabel" />
<label>value :</label> <input type="text" id="txtvalue" name="txtvalue" />
<label>Selected :</label> <input type="checkbox" name="chk_sel" value="chk_sel" />
<label>Required :</label> <input type="checkbox" name="chk_isreq" value="chk_isreq" />
</div>
jQuery
var = question_cnt=1;
$("#div_").clone().find("input,label").andSelf().each(function() {
$(this).show();
$(this).attr('id', this.id +question_cnt );
$(this).attr('name', this.name +question_cnt );
}).appendTo("#container").end();
question_cnt++;
div_, why are you appending them to#container?