Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!