jQuery .html() gets or sets html content of the target element;
Also check jQuery .text()
<script>
$(function(){
var html = $('.target-copy').html(); // copy html
$('.target-paste').html( html ); // paste html
});
</script> |
<script>
$(function(){
var html = $('.target-copy').html(); // copy html
$('.target-paste').html( html ); // paste html
});
</script>
<div class="well">
<strong>copied html:</strong>
<span class="label label-info target-copy">The quick <em>brown fox</em> jumps over the <span style="color:yellow;">lazy dog</span>.</span>
</div>
<div class="well">
<strong>pasted html:</strong>
<span class="label label-success target-paste"></span>
</div> |
<div class="well">
<strong>copied html:</strong>
<span class="label label-info target-copy">The quick <em>brown fox</em> jumps over the <span style="color:yellow;">lazy dog</span>.</span>
</div>
<div class="well">
<strong>pasted html:</strong>
<span class="label label-success target-paste"></span>
</div>