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

209
Vistas
How to display localStorage value in a table header?

I have the following js function that is used to get the saved value of an input field:

function getSavedValue(e) {
    if (!localStorage.getItem(e)) {
        return "";
    }
    return localStorage.getItem(e);
}

The following is an example of how I use this js function:

var paymentMonth = document.getElementById("monthHR_PaymentMonth");

paymentMonth.value = getSavedValue("monthHR_PaymentMonth");

How can I use this function to grab the paymentMonth value and display it in a table column header?:

<th>Payment May 2022</th>

Where May 2022 is the value saved.

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

0

How can I use this function to grab the paymentMonth value and display it in a table column header?: You can try to add an id to the <th></th>:

<th id="monthHR_PaymentMonth"></th>

and then use the following code to add text to it:

$("#monthHR_PaymentMonth").append(getSavedValue("monthHR_PaymentMonth"));
about 4 years ago · Juan Pablo Isaza Denunciar

0

You need the element to have an id attribute in order to get it with the getElementById function. So add an id to the <th>, then use the textContent property to add text to it:

var paymentMonth = document.getElementById("monthHR_PaymentMonth");

paymentMonth.textContent = getSavedValue("monthHR_PaymentMonth");
about 4 years ago · Juan Pablo Isaza Denunciar

0

const paymentMonth = document.getElementById("monthHR_PaymentMonth");
paymentMonth.innerText = getSavedValue("monthHR_PaymentMonth");

use innerText!

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