Hi how could i do to have a space after i display a number.
it seems to me that I saw on stackoverflow that it was necessary to insert "'\ u00A0'" but I do not know where to insert it in my code or maybe I am wrong.
document.getElementById("buttonTry").onclick = takeNumber;
function takeNumber() {
let x = document.getElementById("myNumber").value; document.getElementById("list").appendChild(document.createTextNode(x));
}
.list__number
{
width: 200px;
height: 300px;
border-radius: 15px;
border: thin solid #ccc;
}
#list
{
font-size: 20px;
margin: 10px;
line-height: 1em;
color: red;
white-space:normal;
}
<body>
Number: <input type="number" id="myNumber" value="0">
<p>Click the button to display the number of the number field.</p>
<button id="buttonTry">Try it</button>
<section class="list__number">
<p id="list"></p>
</section>
</body>
You can quite literally insert a space after your number:
document.createTextNode(`${x} `);
document.getElementById("buttonTry").onclick = takeNumber;
function takeNumber() {
let x = document.getElementById("myNumber").value; document.getElementById("list").appendChild(document.createTextNode(`${x} `));
}
.list__number
{
width: 200px;
height: 300px;
border-radius: 15px;
border: thin solid #ccc;
}
#list
{
font-size: 20px;
margin: 10px;
line-height: 1em;
color: red;
white-space:normal;
}
<body>
Number: <input type="number" id="myNumber" value="0">
<p>Click the button to display the number of the number field.</p>
<button id="buttonTry">Try it</button>
<section class="list__number">
<p id="list"></p>
</section>
</body>