在< textarea> ;?中格式化文本
Textareas是伟大的,因为一些内置的功能(滚动条)。如何格式化< textarea>
?
Textareas are great because of some built in functionality (scrollbars). How can I format <spans>
of text inside of the <textarea>
?
如果您需要自定义您的textarea,使用另一个元素(如DIV)重现其行为与 contenteditable
属性。
If you need to customize your textarea, reproduce its behavior using another element (like a DIV) with the contenteditable
attribute.
这是更可定制的,更现代的方法,textarea只是纯文本内容,而不是丰富的内容。
It's more customizable, and a more modern approach, textarea is just for plain text content, not for rich content.
<div id='fake_textarea' contenteditable></div>
滚动条可以使用CSS overflow属性重现。
The scrollbars can be reproduced with the CSS overflow property.
你可以使用这种假的textarea格式正常,例如:如果你必须通过POST方法提交它的内容,你可以做一些类似的事情: / p>
You can use this fake textarea in a form normally, i.e: if you have to submit its content through POST method, you could do something like(with jQuery):
<input type='hidden' id='fake_textarea_content' name='foobar' />
...
$('#your_form').submit(function()
{
$('#fake_textarea_content').val($('#fake_textarea').html());
});