将textarea中的html标记转换为富文本 [英] Convert html tag in textarea to rich text
问题描述
我正在使用PHP填充文本区域:
I am using PHP to fill a textarea:
<textarea text-input" id="Desc" rows="15" wrap="soft" name="Desc"><?php echo $Desc; ?></textarea>
但是文本区域中显示了HTML标记,这是我不想要的.
but the textarea is showing HTML tags in it, which I don't want.
<b>Analog And Digital System</b><br />
<b>Analog System:</b><br />
A string tied to a doorknob would be an analog system. They have a value that changes steadily over time and can have any one of an infinite set of values in a range. If you put a measuring stick or ruler at a specific point along the string, you can measure the string's value every so many seconds at that point. When you watch it move, you will see it moves constantly. It doesn't instantly jump up and down the ruler. <br />
<br />
<b>Digital System:</b><br />
A digital system would be to flick the light switch on and off. There's no 'in between' values, unlike our string. If the switch you are using is not a dimmer switch, then the light is either on, or off. In this case, the transmitter is the light bulb, the media is the air, and the receiver is your eye. This would be a digital system.<br />
基本上我想做的是将<b>
标记转换为粗体,将<br>
标记转换为新行.
Basically what I want to do is convert <b>
tags to make the content bold and <br>
tags to new lines.
我想不使用任何编辑器就做.
I want to do it without using any editor.
推荐答案
无法在textarea内进行HTML格式设置,您将不得不使用ant编辑器,但是如果要在div中显示它,请设置属性contentEditable ="true"可以解决问题
There is no way to to do HTML formatting inside textarea you will have to use ant editor, but if you want to show it in div then setting the attribute contentEditable="true" will do the trick
更多参考信息此处(已在stackoverflow上询问)
more references here (already asked on stackoverflow)
这篇关于将textarea中的html标记转换为富文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!