Convert a jQuery object and contents to string?
Convert a jQuery object and contents to string?
HTML
<input type="button" value="Create New Div" id="btnCreateNewDiv" />
<span id="result"></span>
<div id="testClone" class="Clone" style="display: none;">
<h1>
test
</h1>
</div>
CSS
.Clone
{
background-color: Red;
margin-bottom:10px;
}
.Clone h1
{
color: Lime;
}
JavaScript
$(document).ready(function () {
$('#btnCreateNewDiv').click(function () {
$('#result').append($('<div></div>').append($('#testClone').clone()).html());
$('#result div:last').show();
});
});