javascript - appendTo working with div but not with textarea -
this question has answer here:
- how append text '<textarea>'? 5 answers
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
Post a Comment