东东锅锅
2016-07-25 18:00
document.write("Hello");
document.write("world");
这两句的结果是Helloworld
怎么实现加入空格,或者是换行呢?
加入空格有两种方法,第一种是使用html标签 ,例如document.write(" "+"1"+" "+"23");结果是: 1 23
第二种方法是使用CSS:document.write("<span style='white-space:pre;'>"+" 1 2 3 "+"</span>");结果是: 1 2 3
换行的话直接就document.write("Hello","<br>")就可以实现换行了
不知道有更简便的方法没
world前面直接按键盘输入一个空格可以么,就不输入 ?
html和js可以混合使用的。空格的话就document.write("hello"+" ");document.write("world");
document.write("Hello"+"<br>")就换行了
document.write("Hello"); document.write(" "); document.write("world");
JavaScript入门篇
741097 学习 · 9843 问题
相似问题