[SOLVED] innerHTML append text | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

[SOLVED] innerHTML append text

How can I modify the append in innerHTML? For example: .innerHTML += ("<br />", textvar); Output: textvartextvartextvartextvar Any,help will be appariciated! https://code.sololearn.com/WQXqc89ObFJY/?ref=app

22nd Aug 2018, 11:01 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
3 Answers
+ 3
use .innerHTML += "<br/>"+textvar;
22nd Aug 2018, 11:14 AM
Roel
Roel - avatar
+ 2
+ is used since you want to add the textvar to the breakline no () is used since you dont neccessarily have to add things first, and just add everything in the order you wrote, but dont mind using them, its just not neccessary, but if it looks better to you, go ahead and use them, it wont affect anything
22nd Aug 2018, 11:58 AM
Roel
Roel - avatar
+ 1
Roel, It worked, thanks! Can you give me some explanation on what the difference is between what I did and your answer? Why it worked without () and with + Why it didn't worked with () and ,
22nd Aug 2018, 11:31 AM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar