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

224
Views
How does using variables in javascript work?

I have some simple code here, and I want to test it out, by making the display none, is there something wrong with my javascript? (I'm very new to js)

 var meter = document.getElementById("meter").innerHTML;
        meter.style.display = "none";
<meter id="meter" min="0" max="10"></meter>

The console says meter is undefined, but I defined it right above.

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

0

meter is the innerHTML of the element (which is a string), not the element itself.

Instead, use:

var meter = document.getElementById("meter");
meter.style.display = "none";
<meter id="meter" min="0" max="10"></meter>

If you want to hide it and get its value, you can do:

var meter = document.getElementById("meter");
meter.style.display = "none";
var val = meter.value;
console.log(val)
<meter id="meter" min="0" max="10" value="3"></meter>

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!