在textarea中渲染HTML [英] Rendering HTML inside textarea
本文介绍了在textarea中渲染HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果没有,你知道我可以使用任何jQuery插件吗?
解决方案
这是不可能的如何处理 textarea
。您正在寻找的是 content editable div,这很容易完成:
< div contenteditable =true>< / div>
div.editable {width:300px ; height:200px; border:1px solid #ccc; padding:5px;} strong {font-weight:bold;}
I need to be able to render some HTML tags inside a textarea (namely <strong>, <i>, <u>, <a>) but textareas only interpret their content as text. Is there an easy way of doing it without relying on external libraries/plugins (I'm using jQuery)? If not, do you know of any jQuery plugin I could use to do this?
解决方案
This is not possible to do with a textarea
. What you are looking for is an content editable div, which is very easily done:
<div contenteditable="true"></div>
div.editable {
width: 300px;
height: 200px;
border: 1px solid #ccc;
padding: 5px;
}
strong {
font-weight: bold;
}
<div contenteditable="true">This is the first line.<br>
See, how the text fits here, also if<br>there is a <strong>linebreak</strong> at the end?
<br>It works nicely.
<br>
<br><span style="color: lightgreen">Great</span>.
</div>
这篇关于在textarea中渲染HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文