gpt4 book ai didi

JavaScript document.write br

转载 作者:行者123 更新时间:2023-11-27 23:17:06 25 4
gpt4 key购买 nike

如何用 JavaScript 编写 "<br>" ?我不想让它中断并转到下一行,我只想写入 html 标签。类似于:“html 中的中断标记是...”

下面是我想要的示例。

<script type = "text/javascript">
document.write('"<br>"');
</script>

最佳答案

只需使用 HTML entities .

Character  Entity   Note
--------- ------- ----------------------------------------------------------------
& &amp; Character indicates the beginning of an entity.
< &lt; Character indicates the beginning of a tag
> &gt; Character indicates the ending of a tag
" &quote; Character indicates the beginning and end of an attribute value.

document.write('The break tag in html is &lt;br&gt;.');

关于JavaScript document.write br,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35729596/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com