[英]How to add new div when hitting enter key in contenteditable div
[英]How to add New line to a div contenteditable in javascript?
基本上我使用的是一個帶有contenteditable
的div作為文本框。 現在,當我輸入換行符時(通過按Enter鍵),它不計算它並將其取消。
Jsfiddle: https ://jsfiddle.net/pgsp7q57/3/
你可以輸入:
Hello
How are you
自己看看結果是什么( hellohow are you
)但是我需要得到結果:
Hello
How are you
所有回復都非常感謝。
試試這個代碼 。
var hello = "hello<br>how\nare\nyou";
document.getElementById("hey").innerHTML = hello;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.