用“不可见的”替换textarea的\ n线路断路
console.log('Hello \ nworld');
输出:
Hello
world
如果我将“ Hello [Enter_key] World”写入< textarea>
,则将console。 log($('textarea').html())
输出:
Hello\nworld
如何转换它,以使\ n
未打印而不是在控制台中显示为换行件?
console.log('Hello\nworld');
outputs:
Hello
world
If I write "Hello[ENTER_KEY]world" into a <textarea>
, then console.log($('textarea').html())
outputs:
Hello\nworld
How can I convert this so that \n
isn't printed but shown as a line break in the console?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试获取
value
而不是Innerhtml
Try getting
value
instead ofinnerHTML
尝试使用Textarea 值属性如下:
Try to use textarea value property as below: