如何在javascript中将新行添加到div中?

时间:2017-04-02 05:30:31

标签: javascript jquery html

基本上我使用带有contenteditable的div作为文本框。现在,当我输入换行符时(通过按Enter键),它不会对其进行计数并将其转出。

Jsfiddle:https://jsfiddle.net/pgsp7q57/3/

您可以输入:

Hello
How are you

自己看看结果是(hellohow are you)但是我需要得到结果:

Hello
How are you

非常感谢所有回复。

1 个答案:

答案 0 :(得分:0)

试试这个code

Storm 1.0.3
URL https://git-wip-us.apache.org/repos/asf/storm.git -r eac433b0beb3798c4723deb39b3c4fad446378f4
Branch (no branch)
Compiled by ptgoetz on 2017-02-07T20:22Z
From source with checksum c78e52de4b8a22d99551d45dfe9c1a4b

[root@storm-nimbus-prod]/opt/storm/logs# java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)