你可以在< textarea>里面有一个html列表吗?它看起来像一个列表? [英] Can you have an html list inside a <textarea> and it look like a list?
问题描述
我试过
< textarea rows =10columns =2>< li> joe< /立GT;<李>杰里< /立GT;< / textarea的>
查看是否可以在< textarea>
但它只是显示为文本。有没有什么办法可以把它显示在textarea里面?
c> textarea s - 仅用于纯文本。不过,您可以尝试使用 contentEditable
来做这件事。结果不是很好,但是你是否想用它来判断。只需使用如下所示:
< div class =editablecontenteditable =true>
< ul>
< li>列表项目< / li>
< li>列表项目< / li>
< / ul>
< / div>
这种方法存在的问题是很难预测浏览器将生成的HTML,所产生的HTML真的很残酷,而且你必须比使用纯文本更多地清理输入。另外,这个接口没有在规范中指定,所以你将在不同的浏览器中处理不同的接口。
请参阅: http://www.jsfiddle .net / yijiang / bN2tm / 和 http://html5demos.com/contenteditable
I tried
<textarea rows="10" columns="2"><li>joe</li><li>jerry</li></textarea>
to see if I could put an html list in a <textarea>
but it just showed as text. Is there any way to show it as a list inside the textarea?
You can't have HTML inside textarea
s - it's for plain text only. However, you can try using contentEditable
for this. The result isn't very good, but you be the judge whether you want to use it or not. Simply use something like this:
<div class="editable" contenteditable="true">
<ul>
<li>List item</li>
<li>List item</li>
</ul>
</div>
The problems with this method is that it's difficult to predict what HTML the browser will produce, and that some of the HTML produced are truly atrocious, and that you'll have to sanitise the input a lot more than using plain text. Also, the interface for this isn't specified in the specifications, so you'll be dealing with different interfaces in different browsers.
See: http://www.jsfiddle.net/yijiang/bN2tm/ and http://html5demos.com/contenteditable
这篇关于你可以在< textarea>里面有一个html列表吗?它看起来像一个列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!