我在将\n转换为<br />时遇到问题
function format() {
var text = document.getElementById("formatArea").value;
text.replace("\n", "<br/>");
document.getElementById("resultArea").value = text;
}Run Code Online (Sandbox Code Playgroud)
<textarea rows="20" cols="80" id="formatArea">
</textarea>
<textarea rows="20" cols="80" id="resultArea">
</textarea>
<button onclick="format()">Click to create HTML breaks</button>Run Code Online (Sandbox Code Playgroud)
感谢任何帮助,我在JS方面还不是很有经验.