【发布时间】:2016-05-13 15:28:12
【问题描述】:
1) 在解释器中执行 JavaScript 时 - 我可以使用 esc 序列将一些文本放在第二行 注意:myHeading.textContent 的值在这个屏幕截图中与后面两个不同
> myHeading.textContent + " \n How are things?"
< "Joshua Tree is swell, Laurel Ruth Shimer
How are things?" = $1
2) 但是当我通过从浏览器 (Safari) 调用 html 来使用相同的想法进行测试时,我认为 '\n' 只是被视为 虽然我已经在 html 中完成了这项工作 - 当我在下一行放置一些内容时,HTML 并没有做任何特别的事情。当然,这是有道理的。
var myHeading = document.querySelector('h1');
myHeading.textContent = 'Good to see you again, ' + storedName + ' \n
Write me again soon.' ;
,该标签只是作为文本的一部分包含在内。 html 引擎不会将其读取为实际字符(我不知道该怎么称呼它)
var myHeading = document.querySelector('h1');
myHeading.textContent = 'Good to see you again, ' + storedName + ' <p>
Write me again soon.' ;
我有一个(可能是两个?)关于将 html 放入数组的 Stackoverflow 响应,但我认为这不是一回事。
【问题讨论】:
标签: javascript html safari client-server