jQuery .text()

jQuery .text() gets or sets text content of the target element;

Also check jQuery .html()

js:


$(function(){

    var text = $('.target-copy').text(); // copy text

    $('.target-paste').text( text ); // paste text

});​

html:


<div>

    <strong>copied text:</strong> <span class="target-copy">The quick <em>brown fox</em> jumps over the <span style="color:green;">lazy dog</span>.</span>

</div>



<div>

    <strong>pasted text:</strong> <span class="target-paste"></span>

</div>

Leave a Comment