display html file in a textarea using jquery
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.
精彩评论