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

143
Views
Represent number as currenct from paragraph

On my web page I have an paragraph which looks like this:

<p class="article-content mb-1" id="cost"><strong>Cost [Euro]: </strong>1000000</p>

Number is always something else (which I read from db and represent using Django forms) and I would like to represent it as currency (in this case 1.000.000). I tried to get the value with:

function on_load() {
  var a = document.getElementById('cost').value;
  console.log(a)
}
on_load();
<p class="article-content mb-1" id="cost"><strong>Cost [Euro]: </strong>1000000</p>

but Console output is: 'undefined'. When I get value, I'll use something like

(12345.67).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');  // 12,345.67

To convert to currency.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

p does not have a value attribute. You can do this to get and format the number using intl number format

function on_load() {
  const costs = document.querySelector('#cost');
  let number = costs.childNodes[1].textContent;
  costs.childNodes[1].textContent = new Intl.NumberFormat('de-DE').format(number);
}
on_load();
<p class="article-content mb-1" id="cost"><strong>Cost [Euro]: </strong>1000000</p>

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!