$('#collapseExmaplewell').html("Results number is" + t.finished_hits + "<br />Task results are as following:" + t.detailed_results);
如果t.detailed_results
是JSON字符串,如何将\r
更改为正确的换行符?
答案 0 :(得分:0)
您可以执行以下操作:
var str = t.detailed_results.replace(/\r/g, "<br>");
$('#collapseExmaplewell').html("Results number is" + t.finished_hits + "<br />Task results are as following:" + str);
您应该阅读有关正则表达式here的更多信息。
答案 1 :(得分:0)
$('#collapseExmaplewell').html("Results number is" + t.finished_hits + "<br />Task results are as following:" + t.detailed_results.replace(/\r/g, '\n<br>'));