Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not add white space with 'innerHTML' between buttons

Tags:

People also ask

How do you add a space in innerHTML?

If you MUST use spaces, use   .

Why you shouldn't use innerHTML?

The use of innerHTML creates a potential security risk for your website. Malicious users can use cross-site scripting (XSS) to add malicious client-side scripts that steal private user information stored in session cookies.

How do you keep spaces in JavaScript?

var text = text. replace(/\s/g, ' '); \s will match any white space character, such as space, tab and new line. If you only want to replace space, use / /g instead.


I have this javascript for adding white space between two buttons, I just created and inserted in a div:

document.getElementById("divID").appendChild(buttonONE);

document.getElementById("divID").innerHTML + ="           ";

document.getElementById("divID").appendChild(buttonTWO);

There is a space between the two buttons, but is always just one space, like if you had pressed the space-bar only once.

How can I increase these spaces to more than one?

Thanks