【发布时间】:2011-05-10 10:42:21
【问题描述】:
我有一个字符串:
<Grid><Description>LINE 1
LINE 2
LINE 3
LINE 4
</Description><</Grid>
我需要用换行符对其进行解码。我找到了解决方案:
function decodeString(stringToDecode) {
if (!stringToDecode) {
return stringToDecode;
}
return $('<div />').html(stringToDecode).text();
}
但它会单行并用空格替换所有换行符。
【问题讨论】:
标签: javascript string decode