Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

228
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda