Why is this breaking? I've not used .innerHTML correctly before and don't know why this would be wrong.
function asdf() {
document.getElementById("qwerty").innerHTML="A<br>
B<br>
C<br>
D<br>";
}
Why is this breaking? I've not used .innerHTML correctly before and don't know why this would be wrong.
function asdf() {
document.getElementById("qwerty").innerHTML="A<br>
B<br>
C<br>
D<br>";
}
You have to escape new-lines in JavaScript string-literals:
function asdf() {
document.getElementById("qwerty").innerHTML="A<br>\
B<br>\
C<br>\
D<br>";
}
Though you could, potentially more-easily, simply insert newlines in the string itself:
function asdf() {
document.getElementById("qwerty").innerHTML = "A<br>\nB<br>\nC<br>\nD<br>";
}
Javascript string literals cannot contain newlines.
You can escape the newlines with backslashes:
var myString = "a\
b";
© 2022 - 2024 — McMap. All rights reserved.