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

173
Vistas
Ready Function doesn't Get Value from Input After Page Load

I am having issue waiting on a DOM element to load. I am trying to get the value in an HTML input. Here are the 2 methods that I used but they both did not work:

Option 1):

$(document).ready(function() {
        var inputVal = $(".class-name tag-label");
         if (inputVal != undefined && inputVal.innerText != undefined && inputVal.innerText != ""){
                    //do something
               }
               else{
                    //not to do something
               }
    });

Option 2):

 $(".class-name tag-label").ready(function() {
        var inputVal = $(".class-name tag-label");
         if (inputVal != undefined && inputVal.innerText != undefined && inputVal.innerText != ""){
                    //do something
               }
               else{
                    //not to do something
               }
    });

However, after the page is loaded, and I do $(".class-name tag-label") and it's returning the proper element with a value in the console. Anything I did incorrectly?

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

0

Thanks for your comments. I realized that document was undefined, and was actually missing windows.load

window.addEventListener('load', (event) => {
        var inputVal = $(".class-name tag-label");
        if (inputVal != undefined && inputVal.innerText != undefined && inputVal.innerText != ""){
           //do something
        }
        else{
          //not to do something
        }
   });

This works for me ^

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