使用它会剥离我的 newLine 字符
是否有替代方案可以呈现 html?
function viewCommentToggle( comment )
{
theRow = document.getElementById("id"+comment.id);
idx = 2;
// Comment field
cell = theRow.cells[idx];
while( cell.childNodes.length > 0 ) cell.removeChild(cell.childNodes[0]);
element = document.createTextNode(comment.comment);
cell.appendChild(element);
}
这就是我所关心的:
element = document.createTextNode(comment.comment);
仅供参考....这就是我所做的并且有效:
function viewCommentToggle( comment )
{
theRow = document.getElementById("id"+comment.id);
idx = 2;
// Comment field
//cell = theRow.cells[idx];
// while( cell.childNodes.length > 0 ) cell.removeChild(cell.childNodes[0]);
cell = $("#id"+comment.id+" > td:eq("+idx+")");
$(cell).empty();
$(cell).html( comment.comment == null ? "" : comment.comment.replace(/\n/g,"<br/>").replace(/\r/g,"") );