Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda