如何在JavaScript中编写"<br>"
?我不想让它突破并进入下一行,我只想写html标签。例如:“html中的中断标记是...”JavaScript document.write br
下面是我想要的示例。
<script type = "text/javascript">
document.write('"<br>"');
</script>
如何在JavaScript中编写"<br>"
?我不想让它突破并进入下一行,我只想写html标签。例如:“html中的中断标记是...”JavaScript document.write br
下面是我想要的示例。
<script type = "text/javascript">
document.write('"<br>"');
</script>
只需使用HTML entities。
Character Entity Note --------- ------- ---------------------------------------------------------------- & & Character indicates the beginning of an entity. < < Character indicates the beginning of a tag > > Character indicates the ending of a tag " "e; Character indicates the beginning and end of an attribute value.
document.write('The break tag in html is <br>.');
你可以使用的<
和>
HTML实体:
< : <
> : >
<br> = <br>
Hoep这会有所帮助。
document.write("I don't want <br> to break and go to the next line");
这些是HTML实体,而不是ASCII码。 – Barmar
感谢@Barmar,更新了我的答案。 –
不要使用'document.write',请参阅[规范]警告(http://www.w3.org/TR/html5/webappapis。 HTML文件撰写#%28%29)。改用DOM方法。 – Oriol
在document.write()中,您可以像使用实体一样直接将其放入HTML中,然后执行此操作。 – Barmar