Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
how to make a space with appendChild (document.createTextNode)

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>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda