Html 是否可以在 textarea 中显示粗体和非粗体文本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17456295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to display bold and non-bold text in a textarea?
提问by Jo Smo
I don't want this:
我不想要这个:
<textarea>The <b>color</b> is black.</textarea>
Instead of the <b>
and </b>
i want the text "color" to be shown in bold.
而不是<b>
and</b>
我希望文本“颜色”以粗体显示。
Is this possible?
这可能吗?
采纳答案by lucianosousa
回答by Deep
You Can't style the content of a text area separately, you have to use <div>s, or something similar. This may be a duplicate of:
您不能单独设置文本区域的内容样式,您必须使用 <div> 或类似的东西。这可能是以下内容的副本:
Do you Want Something like this:?
你想要这样的东西:?
http://jsfiddle.net/mekwall/XNkDx/
http://jsfiddle.net/mekwall/XNkDx/
$('.editable').each(function(){
this.contentEditable = true;
});
this allows you to edit the content of a div, and it will still look like a textarea,
这允许您编辑 div 的内容,它仍然看起来像一个文本区域,
Bold Works.
大胆的作品。