HTML显示换行符在textarea中 [英] HTML Display line breaks within textarea

查看:750
本文介绍了HTML显示换行符在textarea中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当您在包含换行符的textarea中捕捉asci文本时,看起来好像是当你打回车时,以换行符的形式插入不可见字符。换行符似乎具有用于返回的格式\r或用于新行的\\\
格式。这些字符在文本中不可见,但在某处。



然而,当我将这段代码放在textarea中时,我无法显示换行符。事实上,我找不到任何放在textarea标签之间的代码显示换行符。



有人可以在textarea中显示换行符,也就是说,

 < textarea>第一行<部分代码>第二行< / textarea> 

我真的试过了你可能想象到的所有东西。例如,如果我尝试< textarea>第一行\r\\\
第二行< / textarea>
它只显示

  `firstline'\r\\\
`第二行

注意:涉及< br> 不会解决这个问题,因为这不是关于html,而是在textarea框中显示纯文本。



谢谢对于在textarea中显示换行符的建议代码。

解决方案

那么,如果您是通过纯HTML完成此操作,那么您可以执行它是两种方式之一。只需按Enter键或使用ASCII字符&#013; &#010;



jsFiddle


I have asked this question now several ways, but still have not gotten an answer.

When you capture asci text in a textarea that includes line breaks, it seems to insert invisible characters in the form of line breaks when you hit return. The line break seems to have the format \r for return or \n for new line. These characters are not visible in the text but are there somewhere.

However, when I put this code in a textarea, I cannot get it to display a linebreak. In fact, I cannot find any code that placed between textarea tags displays a line break.

Can someone show a way to display line breaks in a textarea, ie.

<textarea>first line <some code> second line </textarea>

I have really tried about everything you could possibly imagine. For example, if I try <textarea> first line "\r\n" second line</textarea> it just displays

`firstline "\r\n"` second line

Note: anything involving <br> will not solve this problem as this is not about html, but rather plain text displaying in textarea box.

Thanks for suggested code to display line breaks in textarea.

解决方案

Well if you're doing this through pure HTML, then you can do it one of two ways. Just add lines by pressing enter or using the ASCII characters &#013; &#010;

jsFiddle

这篇关于HTML显示换行符在textarea中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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