你可以在< textarea>里面有一个html列表吗?它看起来像一个列表? [英] Can you have an html list inside a <textarea> and it look like a list?

查看:78
本文介绍了你可以在< textarea>里面有一个html列表吗?它看起来像一个列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过

 < 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 textareas - 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

这篇关于你可以在&lt; textarea&gt;里面有一个html列表吗?它看起来像一个列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆