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

155
Views
i can access the element(input tag) but not its content for neither textContent nor innerText

 <div class="container">
    <input id="word1" type="text"  placeholder="Enter First Word"><br>
    <input  id="submit1" type="submit" name="submit" value="check">
   </div>

    <script type="text/javascript">
        let word1 = document.getElementById('word1');
        let submit = document.getElementById('submit1');

         function display(){
            alert(word1.textContent);
            alert(word1.innerText);
            alert(word1);
            }
        
        submit.addEventListener('click',display,false);
    </script>

the browser alerts with empty string for both textContent and innerText and i don't know why is this happening

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

input doesn't have textContent, if you want get it's value, you need to go with input.value.

<div class="container">
    <input id="word1" type="text"  placeholder="Enter First Word"><br>
    <input  id="submit1" type="submit" name="submit" value="check">
   </div>

    <script type="text/javascript">
        let word1 = document.getElementById('word1');
        let submit = document.getElementById('submit1');

         function display(){
            alert(word1.value);
            }
        
        submit.addEventListener('click',display,false);
    </script>

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!