Add linebreak to textContent or innerText only - in Chrome

随声附和 提交于 2019-11-30 09:19:42

This is because textContent is not aware of style. As a result, e.g., it displays hidden content.

Change c1.textContent to c1.innerText and it will display the line break.

I've solved this by loading a different variable for each situation:

On page load, I use textContent which keeps line breaks intact. When the user starts typing, I use innerText which recognises inserted page breaks. A simple if statement will do the trick!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!