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

201
Vistas
How do I apply CSS to this JS Fetch code to alter text position, font?

New to JS. How can I apply CSS to this JS Fetch to alter test position, font? Thank you.

let file = 'art.txt';
    
const handleFetch = () => {
  fetch(file)
    .then((x) => x.text())
    .then((y) => (document.getElementById('kdkz').innerHTML = y));
};

setInterval(() => handleFetch(), 2000);
 <p id="kdkz"></p>
 

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Just add

#kdkz {
  /*styling here*/
}

The browser will apply the styling after fetching.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Modify the handleFetch() to:

const handleFetch = () => {
    fetch(file)
      .then((x) => x.text())
      .then((y) => {
        const target = document.getElementById('kdkz');
        target.innerHTML = y;
        target.style.textAlign = 'center'; // Change the position here.
      });
  };
  

Or, you can easily add style within the HTML document by using <style> tag before the <body>.

<style>
#kdkz {
  text-align: center; /* Change the position here */
}
</style>
about 4 years ago · Juan Pablo Isaza Denunciar
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