javascript - .innerHTML <br> breaking -
why breaking? i've not used .innerhtml correctly before , don't know why wrong.
function asdf() { document.getelementbyid("qwerty").innerhtml="a<br> b<br> c<br> d<br>"; }
you have escape new-lines in javascript string-literals:
function asdf() { document.getelementbyid("qwerty").innerhtml="a<br>\ b<br>\ c<br>\ d<br>"; }
though could, potentially more-easily, insert newlines in string itself:
function asdf() { document.getelementbyid("qwerty").innerhtml = "a<br>\nb<br>\nc<br>\nd<br>"; }
Comments
Post a Comment