How do I get a CR/LF when setting textContent? I've tried a couple things (below) but these do not work. The \\r\\n
has no effect, the <br />
is displayed literally.
document.getElementById("lbResult").textContent = "\r\nmyID"
document.getElementById("lbResult").textContent = "<br />myID"
You can't, as far as I know. You can do it with innerHTML
though:
document.getElementById("lbResult").innerHTML = "<br />myID";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.