Dany M
Dany M

Reputation: 870

Line break in editable div

I have an editable div

<div id="content" contenteditable ="true">
</div>

I want the user to edit the div and save it into a file (so he can see it again when he come back to the web page). So what I do is basically sent a post request with the div content as a parameter. But the problem is that when the user add a line break, I cant find it in the query post. For example, if the user type this :

Hi there.
I'm Kevin.
What's up ?

I recieve :

Hi there.I'm Kevin.What's up.

The line break have bean trimed or deleted. If I try to show his message, I cant because I loose the line break..

I tried nl2br to show the message, and replaced the div by a textarea but doesn't work.

Any idea?

Upvotes: 0

Views: 1238

Answers (1)

user9746629
user9746629

Reputation:

You can use pre tag. Text in a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks. https://www.w3schools.com/tags/tag_pre.asp

Upvotes: 2

Related Questions