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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:43:52  来源:igfitidea点击:

Is it possible to display bold and non-bold text in a textarea?

javascripthtml

提问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

For these cases, avoid use something pure text area, use wysiwyg html editor.

对于这些情况,避免使用纯文本区域,使用所见即所得的 html 编辑器。

Here are some ideas for you:

这里有一些想法供您参考:

ckeditor

编辑器

niceditor

好编辑

回答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> 或类似的东西。这可能是以下内容的副本:

Format text in a <textarea>?

在 <textarea> 中格式化文本?

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.

大胆的作品。