开发者

display html file in a textarea using jquery

开发者 https://www.devze.com 2023-01-17 03:44 出处:网络
I have a textarea in a form that will eventually be an email form. Using Jquery I have loaded a signature file and want to 开发者_StackOverflow中文版display it in the text area. I have the file but us

I have a textarea in a form that will eventually be an email form. Using Jquery I have loaded a signature file and want to 开发者_StackOverflow中文版display it in the text area. I have the file but using .html displays nothing and using val(data) produces the code on my box . Can anyone offer any help please

    function loadedData(data) {
$('#mail_body').val(data)

}

$.get('../signature/sig1.htm', loadedData);


You cannot put html in a textarea. But you can parse it with jQuery before putting it there.

function loadedData(data) {
   var sig = $("#mysig", data);
   $('#mail_body').val(sig);

}

$.get('../signature/sig1.htm', loadedData);

Or you should use some wysiwyg to add HTML capabilities to your edit box:

http://ckeditor.com/

http://tinymce.moxiecode.com/


textarea elements are not rich-text editors. They can only display plain text. To have a WYSIWYG editor, try TinyMCE.

0

精彩评论

暂无评论...
验证码 换一张
取 消