你如何用JavaScript "<br>"
写作?我不希望它打破并转到下一行,我只想写html标签。类似于:“html中的break标记是......”
以下我想要的例子。
<script type = "text/javascript">
document.write('"<br>"');
</script>
答案 0 :(得分:1)
只需使用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>.');
答案 1 :(得分:0)
您可以使用<
和>
的HTML实体:
< : <
> : >
<br> = <br>
这会有所帮助。
document.write("I don't want <br> to break and go to the next line");
&#13;