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

148
Vistas
How to access returned HTML element

This function defines an HTML element. document.getElementById returns the complete function, not only the h1 element as expected. How I only write what's inside of the two ` (return value).

function tokens() {
        return `
        <h1>test</h1>
    `;
}

document.getElementById('tokens').innerHTML = tokens;
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Change

document.getElementById('tokens').innerHTML = tokens;

to

document.getElementById('tokens').innerHTML = tokens();
about 4 years ago · Juan Pablo Isaza Denunciar

0

You have to call the function with parentheses () in order for it to execute and return the proper output:

document.getElementById('tokens').innerHTML = tokens();
about 4 years ago · Juan Pablo Isaza Denunciar

0

You've written tokens as if it is a variable. Since you want to run a function, add () to tokens. That would be tokens().

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