【发布时间】:2011-11-29 10:52:22
【问题描述】:
我使用 json/jquery/ajax 将数据保存在数据库中。 当我在 textarea 中加载数据时,我得到了我想要的结果。 但是当我在 DIV 中加载数据时,没有换行符。 我用 css 测试了所有东西,包括
white-space:pre;
等等
我将数据保存在 json 中
"', 'text': '" + $('#textInput').val() +
但我也使用 .html() 和 .text() 对其进行了测试。
读取数据:
$('#textOutput').text(data.d.Text);
我在我的 div 中获得了正确的文本,但没有换行符!
文本输出的 CSS
.textOutput // <div> not working, <textarea> working
{
width:100%;
border: 0;
height: auto;
overflow:visible; // also tested with auto etc.
margin: 5px 8px 5px 0px;
font-family: Courier New, Courier;
font-size: 12px;
// white-space:pre;
}
输入的CSS是等价的
【问题讨论】:
-
您的数据库使用什么? php?
标签: jquery ajax json line-breaks