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 Reply

Your email address will not be published. Required fields are marked *