简体   繁体   中英

How to add a white space

I want know how to add white space in JavaScript. I have this line of code:

document.write('<tr align="center"><td>' + txt2.bold().fontcolor("blue") +"                   "+ '</td><td>' +"                   "+  txt3.bold().fontcolor("blue") + '</td></tr><br>');

I want it to do it a different way is there something that I can do to add white space such as Java's "printf()" function where u can add space but doing %s-25 and it will add 25 spaces

You could use Array.join :

new Array(20).join(' ')

or with non-breaking spaces :

new Array(20).join('&nbsp;')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM