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

230
Views
Get javascript to edit text in line on html

I am using jinja to spit out integers into my HTML. I want to convert the integer to USD using JavaScript. My product.cost variable gives the integer 100 and my inttousd() function runs, but does not edit the text inside my HTML. Is there a way to get javascript to update inline or do I have to assign a class to each element and update it that way?

Here is myjinja template:

<script>inttousd("{{ product.cost }}")</script>

Here is a javascript function I made to convert the integer to USD. The console.log shows the function running, but inspect shows everything exactly how jinja saw it except product.cost is given as the integer 100.

function inttousd(str) {
    //Add commas for thousands on first slice
    const [dollars, pennies] = [str.slice(0, -2), str.slice(-2)];
    console.log("$"+dollars+"."+pennies)
    return "$"+dollars+"."+pennies;
}
about 4 years ago · Juan Pablo Isaza
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!