Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!