换行和回车……一定是编码中最复杂的部分。(为了我)
将此代码放在页面中(来自存储为的数据库This from Ricardo\nAnd also a test\nRent 3000.00
):
<td title="This from Ricard
And also a test
Rent 3000.00" style="width:198px;text-align:left">....</td>
然后用它来获取带有'hidden'\n's的title属性
var v = $('#'+i).parent().attr('title'); // i = id of <span> child of <td>
在此过程中,换行符会丢失并使用变量 v 进入文本输入框:
This from RicardAnd also a testRent 3000.00
需要什么来保留并使其\n's
看起来像下面这样?