After cloning, you can process the object in the same way as if it were html already in dom.
For example - html on your page:
<div id="cloneHere"></div> <div class="well" id="buildInfoTemplate"> <form> <fieldset> <legend></legend> <label></label> <input type="text" placeholder="Type something…"> <span class="help-block">Example block-level help text here.</span> <button class="btn">Save</button> </fieldset> </form> </div>
Suppose you wanted to change the text of a help block:
var template = $('#buildInfoTemplate').clone().removeAttr('id'); $('.help-block',template).html('hi there ryan'); $('#cloneHere').append(template);
And you will get:
<div id="cloneHere"> <div class="well"> <form> <fieldset> <legend></legend> <label></label> <input type="text" placeholder="Type something…"> <span class="help-block">hi there ryan</span> <button class="btn">Save</button> </fieldset> </form> </div> </div>
rynop source share