Create element from template element?
The HTML5 provides a template
element:
contents = $('#template').html();
copy = $('<div id="copy"></div>');
$('body').append(copy.append(contents));
The HTML part:
<html>
<body>
<template id='template'>
</template>
</body>
</html>
The clone
method is not sufficient.
Clone the object:
template = $("#template").clone();
template.attr("id","newid");
template.appendTo("body");