+ 4
How do I put a break in JavaScript?
I have a <input> in html and a document.getelementbyid() in JavaScript, and I can't figure out how to put a <br> in the document.getelementbyid() so it will show up in the <input> https://code.sololearn.com/Wl3R6L8nHXPy/?ref=app
4 Answers
+ 5
@Punderful20 Quack,
Apparently the only option to have multiple lines input was by using textarea, and indeed "\n" will turn into a line break in textarea. One more thing is that you named your function with a keyword (break), I recommend you to change the function name, and use textarea instead of input.
https://stackoverflow.com/questions/6262472/multiple-lines-of-input-in-input-type-text
+ 7
Can you link your code with the question? it will help others to understand the question if they can see your code : )
+ 4
You could do something like:
var el = document.getElementById("myElement");
var br = document.createElement("br");
el.appendChild(break);
^Maybe that's what you're asking? Honestly, I'm having trouble understanding exactly what you're asking. What exactly are you trying to do? You want to print <br> inside of the box but not break a line? You're wanting to add a <br> after the input?
Try to explain it a bit further and I'll be happy to help.
+ 3
I tried some random stuff and the answer is "\n"