+ 2
New lines?
Is it possible to have the output of the textarea display new lines? like this ? If so, how? https://code.sololearn.com/W5AR7NmwcPNV/?ref=app
18 Réponses
+ 3
lol
Thanks!
+ 1
Erm.
document.getElementById("textareaid").value += "\nNew Line";
+ 1
Oh. I changed
Para.innerHTML = document.getElementById("MyText").value;
to
Para.innerHTML = "<pre>" + document.getElementById("MyText").value + "</pre>"
It works until you press find Es.
The solution will be to remove the "<pre>" and "</pre>" tags from the p.innerHTML, then replace it.
Let me see what I can do.
+ 1
...I was mid paragraph explaining 😂😂😂
It works perfectly if we change p to pre 😅
Well, we both learn something new today!
+ 1
No need to use pre
Just add .replace(/\n/g, "<br\>");
to force the text with new lines.
https://code.sololearn.com/WvduhrtFCNta/?ref=app
+ 1
Yes..this works too.
https://code.sololearn.com/WcS1n6coUZjY/?ref=app
Note however, if you press the find buttin multiple times. the yellowness around the e gets larger. That's because you need to take out the span each time as well.
+ 1
Well, you can use the replace to replace the spans. I'll see what I can do.
+ 1
Remodified yet again.
Just type away.
+ 1
Oh. Forgot to link it
https://code.sololearn.com/WcS1n6coUZjY/?ref=app
+ 1
And I fixed that too. xD I'm sure there is a better way, but for now here's this.
Maybe Calviղ will come along and fix it I dunno.
+ 1
It just occurred to me that we're using replace several times in the same line of code
If I had known we could do that, I wouldn't have had a few of my problems xD
0
I mean in the output of the code. I want MyPara to display the line breaks from MyText. Is this possible?
0
https://code.sololearn.com/W45hTSA3zAqO/?ref=app
Here's the code for editing. I'll see if I can figure anything out.
0
Can you add comments to explain your changes? I'm new to coding and I want to understand rather than just imitate.
0
wait
0
I googled the HTML pre tag and why didn't we just replace the paragraph tag with the pre tag
0
I actually wanted to find a way to make it only add 1 span, because I was hoping to have it instantly find the E's as you type, but I settled for a button because it kept adding spans.
0
That makes it replace every e with a lowercase e again XD
I have to go now. I'll try to figure it out after work.