javascript - appendTo working with div but not with textarea -


this question has answer here:

i have following jquery code running:

$('a.testlink').click(function() {     var $essay = $(".tinyeditor iframe").contents().find("body").clone();     $essay.appendto("div.test"); }); 

as can see, finding contents of "body" inside iframe (same source); , appending div.

the above code works fine. if change appendto div textarea, doesn't work.

what doing wrong?

.appendto() appends content html. not work textarea. need set value textarea.

for appending inside textarea, need set textarea value original contents + new content.

 $('textarea').val($('textarea').val() + $essay.html()); 

update: what if want contents replaced new one

you need set value using .val() along new content:

$('textarea').val( $essay.html()); 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -