![](/img/trans.png)
[英]How can I remove white space between words in an array using Javascript?
[英]How can i create white space between 2 words in JavaScript?
<html>
<head>
<script>
document.write(“Hello There!”);
document.write(“I’m a Boy”);
</script>
</head>
</html>
您可以使用
添加空格。
喜欢
<html>
<head>
<script>
document.write("Hello There!");
document.write(" ");
document.write("I’m a Boy");
</script>
</head>
</html>
尝试下面的代码-
document.write("Hello There!"); document.write("\ \ \ \ I'm a Boy");
如果要添加换行符,请使用<br />
(不是\\n
因为您正在编写HTML):
document.write("Hello There!"); document.write("<br />"); document.write("I'm a Boy!");
如果需要空格,只需写一个空格:
document.write("Hello There!"); document.write(" "); document.write("I'm a Boy!");
最基本的答案是在字符串的末尾添加一个空格:
document.write("Hello There! ");
document.write("Hello There!");
Hello There! Hello There!
将是结果。
如果要使用多个空间,则必须使用牢不可破的空间:
document.write("Hello There! ");
document.write("Hello There!");
如果对您来说这只是一个有趣的练习,那很好,但是通常,您不想使用空格进行样式设置。 您应该将文本包装在p
或其他html元素中,然后使用css。
您只需要添加
您要在其中添加空间的位置。
<script>
document.write(“Hello There! I am boy”);
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.