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

200
Views
¿Cómo reemplazar el texto de cada nodo DOM usando jQuery?

Me gustaría saber cómo podría analizar el DOM usando jQuery y modificar el texto de cada nodo para traducir una página de mi sitio. Usar jQuery es una restricción, no una elección :)

Para ser más precisos, me gustaría pasar por el DOM, apuntar a cada nodo que contiene texto, traducirlo usando una API y reemplazar el texto original con el traducido.

Me siento un poco perdido aunque parezca bastante simple. ¡Gracias por tu ayuda!

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

0

Si te entiendo correctamente, tendrás algo como

 // use $('*') instead if you really want to use jQuery Array.from(document.querySelectorAll('*')).forEach(async _ => { _.textContent = await myTranslationApi(_.textContent); });

Sin embargo, tendré que decir que a) es lento representar la página con el idioma incorrecto y luego reemplazarlo (esto también podría generar un destello de texto sin traducir) yb) podría ser propenso a errores simplemente introducir el contenido de textContent en su API de traducción (probablemente desee buscar claves de traducción y solo reemplazarlas).

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!