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

132
Views
document.getElementById returns HTMLDivElement {}

I have the following code in my HTML file:

    <div id="calc-parent">
    <div class="row">
    <div class="column" id="calc-display-val">0</div>
    </div>

I need to get the value of calc-display-val, so I have the following JavaScript code:

let calcDisplayVal = document.getElementById("calc-display-val")

function pressOne() {
console.log(calcDisplayVal)
}

But instead of 0, I get "HTMLDivElement {}"

How can I get the value of calc-display-val?

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

0

You can use .innerHTML for this :

let calcDisplayVal = document.getElementById("calc-display-val")

function pressOne() {
  console.log(calcDisplayVal.innerHTML)
}

pressOne()
<div id="calc-parent">
    <div class="row">
    <div class="column" id="calc-display-val">0</div>
</div>

about 4 years ago · Juan Pablo Isaza Report

0

If you need only the print of your div's content:

console.log(document.getElementById("calc-display-val").innerHTML)
<div id="calc-parent">
        <div class="row">
            <div class="column" id="calc-display-val">0</div>
        </div>
</div>

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!