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

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -