Home > Web Front-end > JS Tutorial > What are the two ways of outputting spaces in JavaScript?

What are the two ways of outputting spaces in JavaScript?

一个新手
Release: 2017-10-11 09:38:01
Original
2062 people have browsed it

Two ways to output spaces in Js:

1.Use to output htmltag To solve.        

##document.write(" 

"  
"  
"
"+"A"+" 
 
"+"B");
结果:          A         B
Copy after login


2.

Add the "white-space:pre;

" style attribute when outputting. This style means "whitespace will be retained by the browser".

document.write("<span style =&#39;white-space:pre;&#39;>+"       A        B"+"</span>");
Copy after login
rrree

The above is the detailed content of What are the two ways of outputting spaces in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template